X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fchunk.cpp;h=514431cbdd636209368d86127cf812d5facfcad7;hb=addf4eb6485a36d40096d87196ed786e6e16ab6d;hp=e928a2199b80b2c007ef27d89446e9b41347fb85;hpb=804bde3fc09e4317eef629861638a68bfad3e343;p=blank.git diff --git a/src/chunk.cpp b/src/chunk.cpp index e928a21..514431c 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -9,7 +9,6 @@ namespace blank { Chunk::Chunk() : blocks(Size()) , model() -, transform(1.0f) , dirty(false) { } @@ -17,7 +16,6 @@ Chunk::Chunk() Chunk::Chunk(Chunk &&other) : blocks(std::move(other.blocks)) , model(std::move(other.model)) -, transform(other.transform) , dirty(other.dirty) { } @@ -25,7 +23,6 @@ Chunk::Chunk(Chunk &&other) Chunk &Chunk::operator =(Chunk &&other) { blocks = std::move(other.blocks); model = std::move(other.model); - transform = other.transform; dirty = other.dirty; return *this; } @@ -46,8 +43,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; } } @@ -99,7 +95,10 @@ bool Chunk::Intersection( void Chunk::Position(const glm::vec3 &pos) { position = pos; - transform = glm::translate(pos * Extent()); +} + +glm::mat4 Chunk::Transform(const glm::vec3 &offset) const { + return glm::translate((position - offset) * Extent()); }