#include "ChunkLoader.hpp"
#include "Generator.hpp"
+#include "WorldCollision.hpp"
#include <algorithm>
+#include <iostream>
#include <limits>
#include <queue>
bool Chunk::Intersection(
const AABB &box,
const glm::mat4 &Mbox,
- const glm::mat4 &Mchunk
+ const glm::mat4 &Mchunk,
+ std::vector<WorldCollision> &col
) const noexcept {
- if (!blank::Intersection(box, Mbox, Bounds(), Mchunk)) {
+ bool any = false;
+ float penetration;
+ glm::vec3 normal;
+
+ if (!blank::Intersection(box, Mbox, Bounds(), Mchunk, penetration, normal)) {
return false;
}
for (int idx = 0, z = 0; z < depth; ++z) {
if (!type.visible) {
continue;
}
- if (type.shape->Intersects(Mchunk * ToTransform(Pos(x, y, z), idx), box, Mbox)) {
- return true;
+ if (type.shape->Intersects(Mchunk * ToTransform(Pos(x, y, z), idx), box, Mbox, penetration, normal)) {
+ col.emplace_back(this, idx, penetration, normal);
+ any = true;
}
}
}
}
- return false;
+ return any;
}