On Tue, Aug 28, 2018 at 10:29 AM <[email protected]> wrote: > when calculating cell_width in __init__() function of > CollisionManagerGrid, it says: > > 1. in objects with same size case: > cell_width = 1.25 * object width > > 2. in mixed width case: > cell_width = 1.25 * {width (object): all objects not exceptionally > big} > what does it mean??? > what is the value of cell_width on earth in such case? > > 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 > [image: 捕获.PNG] > > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/cocos-discuss. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/cocos-discuss. For more options, visit https://groups.google.com/d/optout.
