I am generating positions in a random fashion.
In the game world, instantiated elements have a radius, and shouldn't overlap.
The problem is that they will overlap because I use a usual random number generator combined with other fanciness. I can't use other random number generation algorithms where I can guarantee that the elements will never overlap.
A way to solve this is to use a spatial data structure and search for the nearest neighbors in that tree. When I insert an element into that tree, I update it accordingly.
This solution would do the work and it would be fast but my question is:
Is there a dedicated algorithm without that Tree implementation complexity which is faster than O(n²)
?
No comments:
Post a Comment