Recommended Posts

I'm writing some code for basic LOD and detail mapping, and I want to get the distance between my camera and the chunk of terrain (or whatever else the object might be). Is there any other way to do this except to do the distance formula? I was thinking about just taking the distance between the camera and each quadtree node, but I may have a chunk of terrain that straddles the quadtree splitting line and that could screw things up.
I guess my question is, how do most people do this? It seems costly to compute distance for each 33x33 chunk of a 1024x1024 terrain every frame.

0

Share this post

Link to post

Share on other sites

Just sort tiles into quadtree using its center coordinates. there should be no problem. btw computing distance for every tile is not a big deal. you do not even need to take care about all, but the visible ones (you should be able to find them through the quadtree). Once visible tiles found, calculate the distance square between the camera and each object. its 3 multiplications and 2 additions per tile. not a big deal...