X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fchunk.cpp;h=483a4e5cd78ccea1f4722deb31ead2f3cfff0e4a;hb=1a7bbd64b1fef1f4e2f9303f820d6f3ce76cebf1;hp=a485bfbb7d37c61eab4f80c091f1b78659c29b01;hpb=b35ce3a6423c554b34b37362c5550bd705e63a1d;p=blank.git diff --git a/src/chunk.cpp b/src/chunk.cpp index a485bfb..483a4e5 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -7,8 +7,9 @@ namespace blank { Chunk::Chunk() -: blocks(Size()) +: blocks() , model() +, position(0, 0, 0) , dirty(false) { } @@ -28,6 +29,11 @@ Chunk &Chunk::operator =(Chunk &&other) { } +void Chunk::Allocate() { + blocks.resize(Size()); +} + + void Chunk::Draw() { if (dirty) { Update(); @@ -43,8 +49,7 @@ bool Chunk::Intersection( float *dist, glm::vec3 *normal) const { { // rough check - const AABB bb{{0, 0, 0}, {Width(), Height(), Depth()}}; - if (!blank::Intersection(ray, bb, M)) { + if (!blank::Intersection(ray, Bounds(), M)) { return false; } } @@ -94,11 +99,11 @@ bool Chunk::Intersection( return true; } -void Chunk::Position(const glm::vec3 &pos) { +void Chunk::Position(const glm::tvec3 &pos) { position = pos; } -glm::mat4 Chunk::Transform(const glm::vec3 &offset) const { +glm::mat4 Chunk::Transform(const glm::tvec3 &offset) const { return glm::translate((position - offset) * Extent()); }