use of org.terasology.engine.world.internal.ChunkViewCoreImpl in project Terasology by MovingBlocks.
the class ChunkViewTest method testSimpleWorldView.
@Test
public void testSimpleWorldView() {
Chunk chunk = createChunk(0, 0, 0);
chunk.setBlock(new Vector3i(0, 0, 0), solidBlock);
ChunkViewCore chunkView = new ChunkViewCoreImpl(new Chunk[] { chunk }, new BlockRegion(0, 0, 0), new Vector3i(), airBlock);
assertEquals(solidBlock, chunkView.getBlock(0, 0, 0));
}
use of org.terasology.engine.world.internal.ChunkViewCoreImpl in project Terasology by MovingBlocks.
the class ChunkViewTest method testLocalToWorld.
@Test
public void testLocalToWorld() {
Chunk chunk = createChunk(1, 0, 1);
chunk.setBlock(new Vector3i(0, 0, 0), solidBlock);
Chunk[] chunks = new Chunk[] { createChunk(0, 0, 0), createChunk(1, 0, 0), createChunk(2, 0, 0), createChunk(0, 0, 1), chunk, createChunk(2, 0, 1), createChunk(0, 0, 2), createChunk(1, 0, 2), createChunk(2, 0, 2) };
ChunkViewCoreImpl chunkView = new ChunkViewCoreImpl(chunks, new BlockRegion(1, 0, 1).expand(1, 0, 1), new Vector3i(1, 1, 1), airBlock);
assertEquals(new Vector3i(Chunks.SIZE_X, Chunks.SIZE_Y, Chunks.SIZE_Z), chunkView.toWorldPos(new Vector3i()));
}
use of org.terasology.engine.world.internal.ChunkViewCoreImpl in project Terasology by MovingBlocks.
the class ChunkViewTest method testOffsetChunksWorldView.
@Test
public void testOffsetChunksWorldView() {
Chunk chunk = createChunk(1, 0, 1);
chunk.setBlock(new Vector3i(0, 0, 0), solidBlock);
Chunk[] chunks = new Chunk[] { createChunk(0, 0, 0), createChunk(1, 0, 0), createChunk(2, 0, 0), createChunk(0, 0, 1), chunk, createChunk(2, 0, 1), createChunk(0, 0, 2), createChunk(1, 0, 2), createChunk(2, 0, 2) };
ChunkViewCore chunkView = new ChunkViewCoreImpl(chunks, new BlockRegion(1, 0, 1).expand(1, 0, 1), new Vector3i(1, 0, 1), airBlock);
assertEquals(solidBlock, chunkView.getBlock(0, 0, 0));
}
use of org.terasology.engine.world.internal.ChunkViewCoreImpl in project Terasology by MovingBlocks.
the class LocalChunkProvider method getSubview.
@Override
public ChunkViewCore getSubview(BlockRegionc region, Vector3ic offset) {
Chunk[] chunks = new Chunk[region.volume()];
for (Vector3ic chunkPos : region) {
Chunk chunk = chunkCache.get(chunkPos);
int index = (chunkPos.x() - region.minX()) + region.getSizeX() * ((chunkPos.z() - region.minZ()) + region.getSizeZ() * (chunkPos.y() - region.minY()));
chunks[index] = chunk;
}
return new ChunkViewCoreImpl(chunks, region, offset, blockManager.getBlock(BlockManager.AIR_ID));
}
use of org.terasology.engine.world.internal.ChunkViewCoreImpl 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