1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00: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:
Loïc Blot 2020-04-16 08:25:48 +02:00 committed by GitHub
parent 62ae7adab2
commit e8ac5a31cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 55 additions and 39 deletions

View file

@ -35,8 +35,9 @@ public:
bool registerObject(ServerActiveObject *obj) override;
void removeObject(u16 id) override;
void getObjectsInsideRadius(
const v3f &pos, float radius, std::vector<u16> &result);
void getObjectsInsideRadius(const v3f &pos, float radius,
std::vector<ServerActiveObject *> &result,
std::function<bool(ServerActiveObject *obj)> include_obj_cb);
void getAddedActiveObjectsAroundPos(const v3f &player_pos, f32 radius,
f32 player_radius, std::set<u16> &current_objects,