P-152: Virtual World Concept Update 54: Chunked Levels of Detail Using Quad Trees Part 22
I have come up with a solution for the node subdivision problem that I think will work quite well.
I know the node center points, the position of the player, and the view distance of the player. I also know the resolution of each terrain block, which I am calling the “blocksize” (If the max resolution of the terrain is 4096, and the current tier is 2, then each block is 2048×2048, therefore the blocksize is 2048).
I had initially planned take the node center point, and then add and subtract the block size from it, to get the extents of the block. I had then planned to use these extents to determine if the block intersected with the players view distance. This method could potentially have been more accurate than the method I ended up using.
However, I think I have come up with a much simpler idea. I have also determined that the blocksize value that I thought I had may not work, since the node positions are in world space, and the blocksize is not in that scale, so I will need to calculate an equivalent to the block size that works with the numbers that I have.
What I have decided to do is as follows.
Firstly, to get the new blocksize, I realised that the distance between each node center has to be the same. since each node is square, and each node is an identical size. If I assume that the distance between two node centers is “d”, then d divided by 2 is the distance from the node center to the edge of that node. This distance, d/2, is equivalent to the blockSize value that I was using in previous calculations.
Now, if I can assume that the nodes are circular, (or spherical) then I can create a vector from the node center to the players position, and scale that vector by d/2. The point at the end of that vector will be the point closest to the player’s position, so, if the distance between that point and the players current position is less than the players view distance, that node is in view, and should be subdivided, otherwise, it is out of view, and shouldn’t be subdivided.
Assuming that the node is circular should work ok in most cases, the only time a problem could occur is if the players view distance intersects with the very edge of the corner of a node. This could be within the players view distance, but not within the circle described by my algorithm. I think this solution is definitely worth trying, if it doesn’t work, I can try something more complex.