From 7562a79fa214245544cb379423314c3a0766a7f2 Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 14 Aug 2023 03:40:10 +0200 Subject: Generate AABBs for terrain that collides with Player --- src/World/Chunk.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/World/Chunk.cpp') diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp index 8b204c0..6cb67bb 100644 --- a/src/World/Chunk.cpp +++ b/src/World/Chunk.cpp @@ -19,10 +19,6 @@ Chunk::BlockData& Chunk::at(Position::BlockLocal pos) { return at(pos.x(), pos.y(), pos.z()); } -Bool Chunk::is_empty(U32 x, U32 y, U32 z) const { - return at(x, y, z).empty(); -} - ChunkIndex Chunk::index() const { return m_index; } @@ -39,12 +35,19 @@ void Chunk::damage() { m_damaged = true; } -Bool Chunk::is_valid_position(U32 x, U32 y, U32 z) { - return x < Width && y < Height && z < Width; +Bool Chunk::is_valid_position(Position::BlockLocal pos) { + return pos.x() < Width && pos.y() < Height && pos.z() < Width; } U64 Chunk::pos(U32 x, U32 y, U32 z) { return x + Width * y + Width * Height * z; } +AABB Chunk::block_bounds(Position::BlockLocal pos) { + return { + {pos.x(), pos.y(), pos.z()}, + {pos.x() + 1, pos.y() + 1, pos.z() + 1}, + }; +} + } -- cgit 1.4.1