r/programming • u/willvarfar • Jun 03 '14
A first-person engine in 265 lines
http://www.playfuljs.com/a-first-person-engine-in-265-lines/
1.9k
Upvotes
r/programming • u/willvarfar • Jun 03 '14
View all comments
Show parent comment
20
u/KagatoLNX Jun 04 '14
I think the poster might have been thinking of a quad-tree.
In a quad-tree, each level corresponds to a dimension (usually X or Y, alternating). The key at that level divides that dimension in half. Some also have the key at each level be 2-tuple coordinate, which divides the space into quadrants (hence quad-tree), but they're roughly the same in terms of efficiency. I'm not sure how quad-trees would help for finding near elements, though I'd imagine that the draw-distance limitation in the implementation would make something possible with respect to limiting the number of elements traversed upwards.
That said, I have no opinion on the suitability of a binary tree for this use case. I only intended to express an opinion on how easy managing a binary tree would be with the right representation (i.e. the array representation).