IntersectBox works fast with count of objects < 40

Usin intersectBox to check intersect with road borders
It takes N time, cause I check intersect with every object on map

May I speed up usin hash table with distance to objects \ and update this hash table properly

It works, i do calculate distance between object and road borders and only then do intersectBox

are you already using three-mesh-bvh to speed up intersection detection? if not I’d look into using it…

a distance hash table could improve things but you’d ideally want the distance to the bounds of each object (for example if you are using the central position of objects as a distance threshold and you have a long building where it’s center point is outside that threshold and further from the character than the bounds of the building, the collision with the bounds would be ignored entirely, the character then has the potential to be inside the building when / if the distance tolerance is met and the intersection registers) meaning you’d still have to loop each object to figure out it’s bounding box’s bounds distance from the character for a water tight collision system… this is where a bvh tree comes in very useful…