Sign in to follow this  

Ray shooting in a quadtree of non-uniform depth

Recommended Posts

I have a quadtree implemented for collision detection for a 2D game I am working on, and I just finished the actual collision detection and response today. The problem I've run into, however, is ray shooting. Because I opted to use a quadtree which does not constrain itself to a fixed depth, I can't use the canonical node-walking algorithm. I chose to implement my quadtree such that every object is stored in the smallest node which entirely encloses it so that collision detection does not involve duplication of checks. The tree itself is established in the preprocessing stage when the static terrain is added and the tree's subdivisions are built. After that, the quadtree remains static, though I left room for making it dynamic if I need to. I need to be able to find the first n items intersected by the ray, though finding the first item intersected is of higher priority and the first n items thing is more of a gameplay related issue than a physics issue. One slight modification I have to make is that I will probably be doing line tests, not ray tests, because I will be using a beam tree to compute terrain visibility, and the beam tree provides an opportunity to place an upper bound on intersection distance. My current idea is to recursively scan every child node which the ray intersects from closest to farthest, so that if a child node returns an intersection, subsequent child nodes would be skipped. Do you have any recommendations for an algorithm to perform ray shooting using this quadtree implementation? Thanks.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this