Octree Implementation

So far the only state data is color, which I have cached in the octree’s interior nodes. I can add other properties to the BlockState struct, and plan on doing so at a later time, but I don’t know if we should cache anything else in the octree itself. Each property cached adds a considerable memory footprint.

Answering the question “do any leaf nodes in a given area match this color exactly” will not involve the color data cached in the octree’s interior nodes, except maybe a null check to see if the node is completely empty. This is because the interior node’s color, at least as I envision it, is the average color of its child nodes. Looking just at the cached color, you can’t distinguish between a node whose children average out to the color you are searching for, and a node whose children all match the color you are searching for.

When changing the color of a single voxel, if color is cached (which it currently is), all of the nodes up-tree are dirty and must be updated. That does involve querying all eight children to compute a new color; however, I can mark nodes as dirty and batch the update calls, or update lazily, theoretically at a cost of one bit per node.


It may not be necessary or wise to cache even color into the octree. I mentioned this before, but I have no idea how to code for a GPU. Not only do I lack the knowledge, my computer also lacks a dedicated GPU chip… not really sure how that works.

~Max

2 Likes