use of org.terasology.engine.world.ChunkView in project Terasology by MovingBlocks.
the class RenderableWorldImpl method pregenerateChunks.
/**
* @return true if pregeneration is complete
*/
@Override
public boolean pregenerateChunks() {
boolean pregenerationIsComplete = true;
chunkProvider.update();
Chunk chunk;
ChunkMesh newMesh;
ChunkView localView;
for (Vector3ic chunkCoordinates : calculateRenderableRegion(renderingConfig.getViewDistance())) {
chunk = chunkProvider.getChunk(chunkCoordinates);
if (chunk == null) {
pregenerationIsComplete = false;
} else if (chunk.isDirty()) {
localView = worldProvider.getLocalView(chunkCoordinates);
if (localView == null) {
continue;
}
chunk.setDirty(false);
newMesh = chunkTessellator.generateMesh(localView);
newMesh.updateMesh();
newMesh.discardData();
if (chunk.hasMesh()) {
chunk.getMesh().dispose();
}
chunk.setMesh(newMesh);
pregenerationIsComplete = false;
break;
}
}
return pregenerationIsComplete;
}
use of org.terasology.engine.world.ChunkView in project Terasology by MovingBlocks.
the class LodChunkProvider method createChunks.
private void createChunks() {
Block unloaded = blockManager.getBlock(BlockManager.UNLOADED_ID);
try {
while (true) {
Vector3ic pos = neededChunks.take();
// Actually the log scale
Integer scale = requiredChunks.get(pos);
if (scale == null) {
// This chunk is being removed in the main thread.
continue;
}
Chunk chunk = new PreLodChunk(scaleDown(pos, scale), blockManager, extraDataManager);
generator.createChunk(chunk, (1 << scale) * (2f / (Chunks.SIZE_X - 2) + 1));
InternalLightProcessor.generateInternalLighting(chunk, 1 << scale);
// tintChunk(chunk);
ChunkView view = new ChunkViewCoreImpl(new Chunk[] { chunk }, new BlockRegion(chunk.getPosition(new Vector3i())), new Vector3i(), unloaded);
ChunkMesh mesh = tessellator.generateMesh(view, 1 << scale, 1);
readyChunks.add(new LodChunk(pos, mesh, scale));
}
} catch (InterruptedException ignored) {
}
}
Aggregations