/** * Copyright (c) 2025 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "dusk.h" #define CHUNK_WIDTH 16 #define CHUNK_HEIGHT 16 #define CHUNK_DEPTH 32 #define CHUNK_TILE_COUNT (CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH) #define MAP_CHUNK_WIDTH 3 #define MAP_CHUNK_HEIGHT 3 #define MAP_CHUNK_DEPTH 1 #define MAP_CHUNK_COUNT (MAP_CHUNK_WIDTH * MAP_CHUNK_HEIGHT * MAP_CHUNK_DEPTH) typedef int16_t worldunit_t; typedef int16_t chunkunit_t; typedef int8_t chunkindex_t; typedef int32_t worldunits_t; typedef int32_t chunkunits_t; typedef struct worldpos_s { worldunit_t x, y, z; } worldpos_t; typedef struct chunkpos_t { chunkunit_t x, y, z; } chunkpos_t; /** * Compares two world positions for equality. * * @param a The first world position. * @param b The second world position. * @return true if equal, false otherwise. */ bool_t worldPosIsEqual(const worldpos_t a, const worldpos_t b); /** * Converts a world position to a chunk position. * * @param worldPos The world position. * @param out The output chunk position. */ void chunkPosToWorldPos(const chunkpos_t* chunkPos, worldpos_t* out); /** * Converts a chunk position to a world position. * * @param worldPos The world position. * @param out The output chunk position. */ void worldPosToChunkPos(const worldpos_t* worldPos, chunkpos_t* out); /** * Converts a chunk position to a world position. * * @param worldPos The world position. * @param out The output chunk position. */ chunkindex_t chunkPosToIndex(const chunkpos_t* pos);