diff --git a/game/level.cc b/game/level.cc index f1fe491..515f14a 100644 --- a/game/level.cc +++ b/game/level.cc @@ -53,11 +53,13 @@ void Level::load() { void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass, glm::mat4* viewProjectionMatrix, std::vector* shadowVPs) { for(unsigned int i = 0; i(1); - chunks.at(0) = Chunk(); + int numberChunksX = 0; + if (terrain.getHeightmapHeight() % chunkSize == 0) { + numberChunksX = terrain.getHeightmapHeight()/chunkSize; + } + else { + numberChunksX = (terrain.getHeightmapHeight()/chunkSize) + 1; + } + int numberChunksZ = 0; + if (terrain.getHeightmapHeight() % chunkSize == 0) { + numberChunksZ = terrain.getHeightmapHeight()/chunkSize; + } + else { + numberChunksZ = (terrain.getHeightmapHeight()/chunkSize) + 1; + } + chunks = std::vector> (numberChunksX); + for(int i = 0; i zChunks = std::vector(numberChunksZ); + for(int j = 0; j crossChunkObjects; std::vector allObjects; std::vector physicsObjects; - std::vector chunks; + std::vector> chunks; std::vector lights; std::vector triggers; Object* waterPlane;