How to perform efficient 2D picking in HTML5?

Posted by jSepia on Game Development See other posts from Game Development or by jSepia
Published on 2012-06-24T16:49:15Z Indexed on 2012/06/24 21:24 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

I'm currently using an R-Tree for both picking and collision testing. Each entity on screen has a bounding box for collisions and a separate one for picking. Since entities may change position very frequently, both trees must be updated/reordered once per frame.

While this is very efficient for collisions, because the tree is used in hundreds of collision queries every frame, I'm finding it too costly for picking, because it only gets queried when the user clicks, thus leading to a lot of wasted tree updates.

What would be a more efficient way to implement picking without as much overhead?

© Game Development or respective owner

Related posts about 2d

Related posts about JavaScript