X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fchunk.cpp;h=d124eb7373c8b4d34ab65406f4db4bb0cf350ffe;hb=ba93deae894a7e35d95aee32c548ac4e7400c771;hp=e93966e959ce13d4678dfaa3f5870ffcade50e17;hpb=ed3bdc028edc0ecb5835d1c0bf18dbc59b342daf;p=blank.git diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index e93966e..d124eb7 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -368,7 +368,7 @@ float Chunk::GetVertexLight(const RoughLocation::Fine &pos, const BlockMesh::Pos glm::vec3 Chunk::GravityAt(const ExactLocation &coords) const noexcept { - glm::vec3 grav; + glm::vec3 grav(0.0f); for (int index : gravity) { RoughLocation::Fine block_pos(ToPos(index)); ExactLocation block_coords(position, ToCoords(block_pos)); @@ -1075,7 +1075,7 @@ ChunkIndex *ChunkStore::ClosestIndex(const ExactLocation::Coarse &pos) { return closest_index; } -Chunk *ChunkStore::Get(const ExactLocation::Coarse &pos) { +Chunk *ChunkStore::Get(const ExactLocation::Coarse &pos) noexcept { for (ChunkIndex &index : indices) { Chunk *chunk = index.Get(pos); if (chunk) { @@ -1085,6 +1085,16 @@ Chunk *ChunkStore::Get(const ExactLocation::Coarse &pos) { return nullptr; } +const Chunk *ChunkStore::Get(const ExactLocation::Coarse &pos) const noexcept { + for (const ChunkIndex &index : indices) { + const Chunk *chunk = index.Get(pos); + if (chunk) { + return chunk; + } + } + return nullptr; +} + Chunk *ChunkStore::Allocate(const ExactLocation::Coarse &pos) { Chunk *chunk = Get(pos); if (chunk) {