mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02:00
Optimize get_objects_inside_radius calls (#9671)
* Optimize getObjectsInsideRadius calls our previous implementation calls the ActiveObjectMgr to return ids and then lookup those ids in the same map and test each object Instead now we call the global map to return the pointers directly and we ask filtering when building the list using lamba. This drop double looping over ranges of active objects (and then filtered one) and drop x lookups on the map regarding the first call results
This commit is contained in:
@@ -323,9 +323,10 @@ public:
|
||||
bool swapNode(v3s16 p, const MapNode &n);
|
||||
|
||||
// Find all active objects inside a radius around a point
|
||||
void getObjectsInsideRadius(std::vector<u16> &objects, const v3f &pos, float radius)
|
||||
void getObjectsInsideRadius(std::vector<ServerActiveObject *> &objects, const v3f &pos, float radius,
|
||||
std::function<bool(ServerActiveObject *obj)> include_obj_cb)
|
||||
{
|
||||
return m_ao_manager.getObjectsInsideRadius(pos, radius, objects);
|
||||
return m_ao_manager.getObjectsInsideRadius(pos, radius, objects, include_obj_cb);
|
||||
}
|
||||
|
||||
// Clear objects, loading and going through every MapBlock
|
||||
|
Reference in New Issue
Block a user