From: Daniel Karbach Date: Fri, 28 Aug 2015 14:05:27 +0000 (+0200) Subject: sort chunk candidates before detailed check X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=dd1849e2313c37fe60fe385ef460f53c3628b447;p=blank.git sort chunk candidates before detailed check this makes the check from nearest to farthest which should save a lot of work. too bad that profiling currently runs with the aim pointing into nothingness, so results aren't visible. may have to check that again some time --- diff --git a/src/world/World.cpp b/src/world/World.cpp index 592558b..1d25e01 100644 --- a/src/world/World.cpp +++ b/src/world/World.cpp @@ -6,6 +6,7 @@ #include "../graphics/Format.hpp" #include "../graphics/Viewport.hpp" +#include #include #include #include @@ -42,6 +43,10 @@ struct Candidate { float dist; }; +bool CandidateLess(const Candidate &a, const Candidate &b) { + return a.dist < b.dist; +} + std::vector 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::infinity();