BorisTheBrave
|
|
« Reply #1 on: June 16, 2017, 03:38:37 AM » |
|
You can use quadtrees on non powers of two. Just round up, and null out branches you don't need. While that sounds wasteful, the quad tree will only be max one branch deeper than something more optimal, which is fine.
---
In terms of edge data, as you know, the easiest way to store edge data for a planar tiling is to store the top and left edges of each tile with the tile. If you want to know the bottom or right edges, you move one tile down or right, then ask what their top/left edge is.
Turns out, you can do the same thing for a cube. There's 12 edges on a cube, and 6 faces, and if you pick the right rotations for each face, then each tile can have a "top" edge and a "left" edge, and you cover all all edges exactly once that way.
That extends very naturally to a tiled cube. Ultimately, every tile sees 4 tiles as neighbours, so you can locally treat it like a grid. But when a neighbour tile happens to be in another cube face, then there is a rotation in local co-ordinates when crossing the boundary.
----
Though I've not done exactly this, when writing these systems, I like to abstract the geometry into a library, so I don't have to think about it elsewhere. You have a class like TileLocationWithDirection, and then have methods Forward, Rotate90, etc. Then you need two dictionary like objects for storing per-location and per-edge information, which are keyed by TileLocation[WithDirection]. If you are working with levels of detail, then the same thing applies, but you have TilLocationWithDirectionAndLevel, and extra operations GetParent / GetChildren.
It's not a perfect abstraction, but you can get pretty far with it without having to worry about special cases.
|