// Copyright (c) 2021 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include #include #include "chunk.h" #include "./../util/math.h" typedef struct { /** Dimensions of the chunk list */ int32_t width, height, depth; /** Position of index 0 */ int32_t x, y, z; /** Count of chunks in the internal array */ int32_t count; /** Current order of each chunk in the list. */ chunk_t **chunkList; /** The actual chunks in the list */ chunk_t *chunks; } chunklist_t; /** * Creates a new chunk list. Chunk lists are managed to be memory efficient by * only keeping a small fraction of the overall size loaded at any given time. * * @param width The width (x axis) of chunks to keep loaded. * @param height The height (y axis) of chunks to keep loaded. * @param depth The depth (z axis) of chunks to keep loaded. * @returns A new chunk list. */ chunklist_t * chunkListCreate(int32_t width, int32_t height, int32_t depth); /** * Disposes and frees a previously created list. This does not free the chunks * themselves. * @param list The list to free. */ void chunkListDispose(chunklist_t *list); /** * Shift the chunk list along a set of axis (in absolute space). * * @param list List to shift. * @param x X movement to shift chunk along. * @param y Y movement to shift chunk along. * @param z Z movement to shift chunk along. */ void chunkListShift(chunklist_t *list, int32_t x, int32_t y, int32_t z);