mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Optimize getting active objects a bit. #8674
This commit is contained in:
parent
41229696be
commit
9fe3246154
3 changed files with 11 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue