From 36c08193ba12037322c93791d03e72a0d3d28c9d Mon Sep 17 00:00:00 2001 From: mimo Date: Wed, 30 Dec 2015 13:44:51 +0000 Subject: [PATCH] optimizes range queries, fixes #3717 This was SVN commit r17573. --- source/simulation2/components/CCmpRangeManager.cpp | 2 ++ source/simulation2/helpers/Spatial.h | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/simulation2/components/CCmpRangeManager.cpp b/source/simulation2/components/CCmpRangeManager.cpp index 4d7bdd8d49..4d88c7effe 100644 --- a/source/simulation2/components/CCmpRangeManager.cpp +++ b/source/simulation2/components/CCmpRangeManager.cpp @@ -1087,6 +1087,7 @@ public: r.push_back(it->first); } + std::sort(r.begin(), r.end()); } // check a regular range (i.e. not the entire world, and not parabolic) else @@ -1117,6 +1118,7 @@ public: r.push_back(it->first); } + std::sort(r.begin(), r.end()); } } diff --git a/source/simulation2/helpers/Spatial.h b/source/simulation2/helpers/Spatial.h index aa61d8a746..c44f8e3cbc 100644 --- a/source/simulation2/helpers/Spatial.h +++ b/source/simulation2/helpers/Spatial.h @@ -514,8 +514,8 @@ public: } /** - * Returns a sorted list of items that are either in the square or close to it. - * It's the responsibility of the querier to do proper distance checking. + * Returns a (non sorted) list of items that are either in the square or close to it. + * It's the responsibility of the querier to do proper distance checking and entity sorting. */ void GetInRange(std::vector& out, CFixedVector2D posMin, CFixedVector2D posMax) { @@ -545,13 +545,11 @@ public: out.insert(out.end(), subdivision.begin(), subdivision.end()); } } - - std::sort(out.begin(), out.end()); } /** - * Returns a sorted list of items that are either in the circle or close to it. - * It's the responsibility of the querier to do proper distance checking. + * Returns a (non sorted) list of items that are either in the circle or close to it. + * It's the responsibility of the querier to do proper distance checking and entity sorting. */ void GetNear(std::vector& out, CFixedVector2D pos, entity_pos_t range) {