Search in sources :

Example 1 with PreLodChunk

use of org.terasology.engine.world.chunks.internal.PreLodChunk 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) {
    }
}
Also used : PreLodChunk(org.terasology.engine.world.chunks.internal.PreLodChunk) ChunkViewCoreImpl(org.terasology.engine.world.internal.ChunkViewCoreImpl) ChunkMesh(org.terasology.engine.rendering.primitives.ChunkMesh) Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) Block(org.terasology.engine.world.block.Block) BlockRegion(org.terasology.engine.world.block.BlockRegion) PreLodChunk(org.terasology.engine.world.chunks.internal.PreLodChunk) PreLodChunk(org.terasology.engine.world.chunks.internal.PreLodChunk) ChunkView(org.terasology.engine.world.ChunkView)

Aggregations

Vector3i (org.joml.Vector3i)1 Vector3ic (org.joml.Vector3ic)1 ChunkMesh (org.terasology.engine.rendering.primitives.ChunkMesh)1 ChunkView (org.terasology.engine.world.ChunkView)1 Block (org.terasology.engine.world.block.Block)1 BlockRegion (org.terasology.engine.world.block.BlockRegion)1 PreLodChunk (org.terasology.engine.world.chunks.internal.PreLodChunk)1 ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)1