Hacker News new | ask | show | jobs
by adam-a 4475 days ago
The other way to do this, which is common in (older?) 3d video games, is to render your scene twice, once normally and once with each object shaded in a unique flat colour. Then sample your second bitmap at the mouse position and map the pixel value back to your list of objects. This is very fast and only falls over when you start to have transparent objects, in which case ray-casting and r-trees become appropriate.
1 comments

This is basically a grid[1] where the resolution is down to 1 pixel. Not a bad solution!

[1]: http://en.wikipedia.org/wiki/Grid_(spatial_index)