aboutsummaryrefslogtreecommitdiff
path: root/src/server
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/server
parent41229696be5878effa53a9a754766857d70f417d (diff)
downloadminetest-9fe32461540316d9ef06b2f06c02684c36c5fa94.tar.gz
minetest-9fe32461540316d9ef06b2f06c02684c36c5fa94.tar.bz2
minetest-9fe32461540316d9ef06b2f06c02684c36c5fa94.zip
Optimize getting active objects a bit. #8674
Diffstat (limited to 'src/server')
-rw-r--r--src/server/activeobjectmgr.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/server/activeobjectmgr.cpp b/src/server/activeobjectmgr.cpp
index 56febd76e..01d9d5ae8 100644
--- a/src/server/activeobjectmgr.cpp
+++ b/src/server/activeobjectmgr.cpp
@@ -115,11 +115,12 @@ void ActiveObjectMgr::removeObject(u16 id)
void ActiveObjectMgr::getObjectsInsideRadius(
const v3f &pos, float radius, std::vector<u16> &result)
{
+ float r2 = radius * radius;
for (auto &activeObject : m_active_objects) {
ServerActiveObject *obj = activeObject.second;
u16 id = activeObject.first;
const v3f &objectpos = obj->getBasePosition();
- if (objectpos.getDistanceFrom(pos) > radius)
+ if (objectpos.getDistanceFromSQ(pos) > r2)
continue;
result.push_back(id);
}