Suppose you have 100 collidables with dimensions between 16 and 32, and then four big collidables 400 x 400
A good cell_width would be 1.25 * 32
A grid collision maneager works by
- breaks the world in cells
- each object is added to all the cells its overlap
- when asking for collision with object A, we need to look only in the cells overlapped by A
So, if the cell size is too big they are too many objects to look in each cell.
On the other side, if cell size is too small, object A will overlap too many cells.
If all the collidables are same size,and small relative to world size, cell_width as 1.25 * cell_width works well.
What if all the collidables are small relative to world size but not same size?. Well, 1.25 * max_width may be good enough.
What if a few big objects are added to the previous scenary ? Discard the big objects to calculate cell_width
What if theres no small size bigger than most of collidables sizes? Then probably the grid manager will not behave well, a quadtree would be better suited
You received this message because you are subscribed to the Google Groups "cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos-discus...@googlegroups.com.
To post to this group, send email to cocos-...@googlegroups.com.
Visit this group at https://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/d/optout.