Search in sources :

Example 1 with ChunkView

use of org.terasology.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.completeUpdate();
    chunkProvider.beginUpdate();
    RenderableChunk chunk;
    ChunkMesh newMesh;
    ChunkView localView;
    for (Vector3i 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, ChunkConstants.SIZE_Y, 0);
            newMesh.generateVBOs();
            if (chunk.hasMesh()) {
                chunk.getMesh().dispose();
            }
            chunk.setMesh(newMesh);
            pregenerationIsComplete = false;
            break;
        }
    }
    return pregenerationIsComplete;
}
Also used : ChunkMesh(org.terasology.rendering.primitives.ChunkMesh) RenderableChunk(org.terasology.world.chunks.RenderableChunk) Vector3i(org.terasology.math.geom.Vector3i) ChunkView(org.terasology.world.ChunkView)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)1 ChunkMesh (org.terasology.rendering.primitives.ChunkMesh)1 ChunkView (org.terasology.world.ChunkView)1 RenderableChunk (org.terasology.world.chunks.RenderableChunk)1