Added a parameter to getSurroundingChunks to limit the chunkRenderDistance.

This commit is contained in:
Faerbit 2015-05-28 11:23:27 +02:00
parent 9ea1630057
commit b110551db6
2 changed files with 10 additions and 5 deletions

View File

@ -141,14 +141,19 @@ void Level::enqueueObjects(Graphics* graphics) {
graphics->enqueueObjects(&sortedCrossChunkObjects);
}
std::vector<Chunk*> Level::getSurroundingChunks() {
std::vector<Chunk*> Level::getSurroundingChunks(int chunkRenderDistance) {
int renderDistance = 0;
if (chunkRenderDistance < 0) {
if ((int)farPlane % chunkSize == 0) {
renderDistance = (((int)skydomeSize)+chunkSize/2)/chunkSize;
}
else {
renderDistance = ((((int)skydomeSize)+chunkSize/2)/chunkSize) + 1;
}
}
else {
renderDistance = chunkRenderDistance;
}
int xPosition = ((int)cameraCenter->getPosition().x + (terrain.getHeightmapWidth()/2))/chunkSize;
int zPosition = ((int)cameraCenter->getPosition().z + (terrain.getHeightmapHeight()/2))/chunkSize;
int xStart = xPosition - renderDistance;

View File

@ -86,7 +86,7 @@ class Level {
void sortObjects(int textureCount);
std::vector<Light*>* getClosestLights();
private:
std::vector<Chunk*> getSurroundingChunks();
std::vector<Chunk*> getSurroundingChunks(int chunkRenderDistance);
lua_State* luaState=nullptr;
std::vector<Object*> crossChunkObjects;
std::vector<std::vector<Object*>> sortedCrossChunkObjects;