This content has been marked as final. Show 4 replies
divide your collision region into sections that have are the size of your smallest object. assign each object to its current section. each section needs to retrieve the objects within it. you need a look-up table or easy way to determine adjacent sections. assign each section an id #.
to efficiently detect pair-wise relations (like hittests) between all object pairs, check for relations between all objects in the section with the lowest id# and adjacent section. increment the id# and repeat.
You mean like creating a table for a grid and check only the upper lower
and side elements in the corresponding lists? Sounds good.
What I don't understand is the part with the lowest ID.
ordering your sections allows you to cut the calculations in 1/2. instead of having each region check all adjacent regions, each region only needs to check adjacent regions greater (or lesser, depending on whether you're starting with earlier or later regions) than itself.
There is some really good work at polygonal.de.