]> git.localhorst.tv Git - blank.git/blobdiff - src/world/World.cpp
first draft for client/server architecture
[blank.git] / src / world / World.cpp
index 592558b303a943e655fac9eec3f43f5dc7471755..1d25e01ba2acd61289aac298a5cccbded2d35f68 100644 (file)
@@ -6,6 +6,7 @@
 #include "../graphics/Format.hpp"
 #include "../graphics/Viewport.hpp"
 
+#include <algorithm>
 #include <limits>
 #include <glm/gtx/io.hpp>
 #include <glm/gtx/transform.hpp>
@@ -42,6 +43,10 @@ struct Candidate {
        float dist;
 };
 
+bool CandidateLess(const Candidate &a, const Candidate &b) {
+       return a.dist < b.dist;
+}
+
 std::vector<Candidate> candidates;
 
 }
@@ -63,6 +68,8 @@ bool World::Intersection(
 
        if (candidates.empty()) return false;
 
+       std::sort(candidates.begin(), candidates.end(), CandidateLess);
+
        coll.chunk = nullptr;
        coll.block = -1;
        coll.depth = std::numeric_limits<float>::infinity();