-void World::Generate() {
- for (int z = -2; z < 3; ++z) {
- for (int y = -2; y < 3; ++y) {
- for (int x = -2; x < 3; ++x) {
- Generate(glm::vec3(x, y, z));
+namespace {
+
+bool ChunkLess(const Chunk &a, const Chunk &b) {
+ return dot(a.Position(), a.Position()) < dot(b.Position(), b.Position());
+}
+
+}
+
+void World::Generate(const glm::tvec3<int> &from, const glm::tvec3<int> &to) {
+ for (int z = from.z; z < to.z; ++z) {
+ for (int y = from.y; y < to.y; ++y) {
+ for (int x = from.x; x < to.x; ++x) {
+ glm::vec3 pos{float(x), float(y), float(z)};
+ if (x == 0 && y == 0 && z == 0) {
+ loaded.emplace_back();
+ loaded.back().Position(pos);
+ Generate(loaded.back());
+ } else {
+ to_generate.emplace_back();
+ to_generate.back().Position(pos);
+ }