unity3d - Data structure for irregular grid -


I'm wondering what is the best data structure for the grid in which different size rectangular / square game map sectors are. I need an XIG object which is within the grid by simple Xyz coordinates.

Enter image details here searched for KdTrees, but they get the closest thing I also get trees / gaps in the segment, but there is some information about Cheers.

This is you can use an octree, you can start with a rectangular parallel pip In which the entire region is ((0, 0, 0), (x, y, z)) (this is the root of the tree). In the next step, divide it into 8 rectangular parallel pipid ((0, 0, 0), (x / 2, y / 2, z / 2)), ((0, 0, z / 2), (x / 2, y / 2, z)) and so on). These are 8 rectangular parallel piped children of origin. Repeat the tree for each of them when a rectangular parallel is completely within an area, then recursion should be stopped (hence it becomes the leaves of the tree).

To answer a question, start with the root of octree and go to a proper child until you reach the leaf.

It is possible to adapt the KD tree to solve this problem. This idea is similar to the one described above: Divide the space into two half-dimensions, create a tree for each of them. The case of recurrence is also the same: Once the current sub-space is only within one area, then recursion should be stopped.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -