Tile under foot
This commit is contained in:
@@ -23,6 +23,18 @@ void worldPosToChunkPos(const worldpos_t* worldPos, chunkpos_t* out) {
|
||||
out->z = (chunkunit_t)(worldPos->z / CHUNK_DEPTH);
|
||||
}
|
||||
|
||||
chunktileindex_t woprldPosToChunkTileIndex(const worldpos_t* worldPos) {
|
||||
uint8_t localX = (uint8_t)(worldPos->x % CHUNK_WIDTH);
|
||||
uint8_t localY = (uint8_t)(worldPos->y % CHUNK_HEIGHT);
|
||||
uint8_t localZ = (uint8_t)(worldPos->z % CHUNK_DEPTH);
|
||||
|
||||
return (chunktileindex_t)(
|
||||
(localZ * CHUNK_WIDTH * CHUNK_HEIGHT) +
|
||||
(localY * CHUNK_WIDTH) +
|
||||
localX
|
||||
);
|
||||
}
|
||||
|
||||
chunkindex_t chunkPosToIndex(const chunkpos_t* pos) {
|
||||
return (chunkindex_t)(
|
||||
(pos->z * MAP_CHUNK_WIDTH * MAP_CHUNK_HEIGHT) +
|
||||
|
||||
Reference in New Issue
Block a user