Seeing Spheres

Looks like I dropped the ball on a weekly journal, but that's okay! I took a break from everything and had a vacation (i.e., I visited my friends and family back in Canada). Back in the game and played around with "voxelizing" spheres.

outside the sphereinside the sphere
A solid sphere + inside a spherical cutout.

Although I could use this as a "brush" for creating voxel landscapes, my guiding reason for creating a voxel sphere is for finding a radius of chunks around the player to load. Right now I grab a cube of chunks, so to speed things up I can just grab a sphere of chunks. I'll also reduce the amount of data I'm loading into memory. Eventually I'll also do some frustrum culling so I don't render unnecessary chunks.

My approach is rather simple and likely not perfect, but for now it'll get the job done. It's simply an extension of the midpoint circle algorithm for three dimensions. In Python it looks something like this:

def sphere(cx, cy, cz, radius):
    for p1, radiusError in midpointCircle(radius):
        for p2, _ in midpointCircle(p1.x, radiusError):
            yield cx + p2.x, cy + p1.y, cz + p2.y

Some optimization tasks that I plan on working in the near future:

Outside of that, I have a few other tasks to work on: