summaryrefslogtreecommitdiff
path: root/src/client/activeobjectmgr.cpp
diff options
context:
space:
mode:
authorLars Hofhansl <larsh@apache.org>2019-07-16 15:55:17 -0700
committerLars Hofhansl <larsh@apache.org>2019-07-16 15:55:17 -0700
commit9fe32461540316d9ef06b2f06c02684c36c5fa94 (patch)
treeb047d363f95a5e91fc89e4fff6fa3f010c1f5e32 /src/client/activeobjectmgr.cpp
parent41229696be5878effa53a9a754766857d70f417d (diff)
downloadminetest-9fe32461540316d9ef06b2f06c02684c36c5fa94.tar.gz
minetest-9fe32461540316d9ef06b2f06c02684c36c5fa94.tar.bz2
minetest-9fe32461540316d9ef06b2f06c02684c36c5fa94.zip
Optimize getting active objects a bit. #8674
Diffstat (limited to 'src/client/activeobjectmgr.cpp')
-rw-r--r--src/client/activeobjectmgr.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/client/activeobjectmgr.cpp b/src/client/activeobjectmgr.cpp
index 4ed98d79b..9fd8490f2 100644
--- a/src/client/activeobjectmgr.cpp
+++ b/src/client/activeobjectmgr.cpp
@@ -91,15 +91,16 @@ void ActiveObjectMgr::removeObject(u16 id)
void ActiveObjectMgr::getActiveObjects(const v3f &origin, f32 max_d,
std::vector<DistanceSortedActiveObject> &dest)
{
+ f32 max_d2 = max_d * max_d;
for (auto &ao_it : m_active_objects) {
ClientActiveObject *obj = ao_it.second;
- f32 d = (obj->getPosition() - origin).getLength();
+ f32 d2 = (obj->getPosition() - origin).getLengthSQ();
- if (d > max_d)
+ if (d2 > max_d2)
continue;
- dest.emplace_back(obj, d);
+ dest.emplace_back(obj, d2);
}
}