Jump to content
  • Advertisement
Sign in to follow this  

Ray shooting in a quadtree of non-uniform depth

This topic is 4477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!