Quote:
This can take adges to explain...but I try it in the short way first....
You devide the map up in a power of 2 size first...lets say 8bits. That will say that one side of the map is 0 and the other is 255.
If you have something situated in position 128.3 to 128.8 (X pos) then XOR these (int) values
10000000
10000000
-------------
00000000
there is now no "1" bit in the result, so we get 0 for the position. if you have 9 levels in the quad tree, then say 9-0 and you know it is in the 9th level.
Once the level in the tree has been determined, the only step remainin is to take the scale coordinates and extract the row and column position of the target node. If the target node is on the bottom level (stupid example by me since I got level 9 in a 9level tree), no scaling will be necessary. For each level up the tree, the target coordinates hae to be scaled down bny 2 to reflect the smaller number of nodes on that level. This scaling can be done simply by right-shifting the integer coordinates by the number of levels the target is from the bottom level. This gives the row and column positions to plug into the array lookup for nodes on that level of thequadtree
Eh.. i've got stuck at the "so we get 0" is the position=the result of xor?