-
Notifications
You must be signed in to change notification settings - Fork 52
Optimizing tests by getting only entities nearby
Roberto de Deus Barbosa Murta edited this page Nov 8, 2019
·
2 revisions
When performing collision, intersection or proximity tests it is better to perform those tests, which commonly involve lots of processing, only on entities that are in the buckets nearby the object's location. It avoids having to perform expensive tests on entities that are too far.
Functions like GetEntitiesAroundBucket
or GetEntitiesAroundEntity
seek entities in the area. Sample:
vector2 bombPos(200.0f, 300.0f);
vector2 bombBucket = GetBucket(bombPos);
ETHEntityArray entities;
// Copies into 'entities' a handle to each entity contained in the buckets around 'bombBucket'
GetEntitiesAroundBucket(bombBucket, entities);
for (uint t = 0; t < entities.Size(); t++)
print(entities[t].GetEntityName() + " is around the bomb! Careful!");