]> git.localhorst.tv Git - blank.git/blobdiff - src/chunk.cpp
limit chunks allocated/freed per frame
[blank.git] / src / chunk.cpp
index 514431cbdd636209368d86127cf812d5facfcad7..483a4e5cd78ccea1f4722deb31ead2f3cfff0e4a 100644 (file)
@@ -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();
@@ -93,11 +99,11 @@ bool Chunk::Intersection(
        return true;
 }
 
-void Chunk::Position(const glm::vec3 &pos) {
+void Chunk::Position(const glm::tvec3<int> &pos) {
        position = pos;
 }
 
-glm::mat4 Chunk::Transform(const glm::vec3 &offset) const {
+glm::mat4 Chunk::Transform(const glm::tvec3<int> &offset) const {
        return glm::translate((position - offset) * Extent());
 }