Search in sources :

Example 46 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class ChunkViewTest method testOffsetWorldViewBeforeMainChunk.

@Test
public void testOffsetWorldViewBeforeMainChunk() {
    Chunk chunk = createChunk(0, 0, 0);
    chunk.setBlock(new Vector3i(Chunks.SIZE_X - 1, 0, Chunks.SIZE_Z - 1), solidBlock);
    Chunk[] chunks = new Chunk[] { chunk, createChunk(0, 0, -1), createChunk(1, 0, -1), createChunk(-1, 0, 0), createChunk(0, 0, 0), createChunk(1, 0, 0), createChunk(-1, 0, 1), createChunk(0, 0, 1), createChunk(1, 0, 1) };
    ChunkViewCore chunkView = new ChunkViewCoreImpl(chunks, new BlockRegion(0, 0, 0).expand(1, 0, 1), new Vector3i(1, 0, 1), airBlock);
    assertEquals(solidBlock, chunkView.getBlock(-1, 0, -1));
}
Also used : ChunkViewCoreImpl(org.terasology.engine.world.internal.ChunkViewCoreImpl) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk) ChunkViewCore(org.terasology.engine.world.internal.ChunkViewCore) Test(org.junit.jupiter.api.Test)

Example 47 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class ChunkViewTest method testOffsetWorldView.

@Test
public void testOffsetWorldView() {
    Chunk chunk = createChunk(0, 0, 0);
    chunk.setBlock(new Vector3i(0, 0, 0), solidBlock);
    Chunk[] chunks = new Chunk[] { createChunk(-1, 0, -1), createChunk(0, 0, -1), createChunk(1, 0, -1), createChunk(-1, 0, 0), chunk, createChunk(1, 0, 0), createChunk(-1, 0, 1), createChunk(0, 0, 1), createChunk(1, 0, 1) };
    ChunkViewCore chunkView = new ChunkViewCoreImpl(chunks, new BlockRegion(0, 0, 0).expand(1, 0, 1), new Vector3i(1, 0, 1), airBlock);
    assertEquals(solidBlock, chunkView.getBlock(0, 0, 0));
}
Also used : ChunkViewCoreImpl(org.terasology.engine.world.internal.ChunkViewCoreImpl) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk) ChunkViewCore(org.terasology.engine.world.internal.ChunkViewCore) Test(org.junit.jupiter.api.Test)

Example 48 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class RenderableWorldImpl method calculateRenderableRegion.

private BlockRegion calculateRenderableRegion(ViewDistance newViewDistance) {
    Vector3i cameraCoordinates = calcCameraCoordinatesInChunkUnits();
    Vector3ic renderableRegionSize = newViewDistance.getChunkDistance();
    Vector3i renderableRegionExtents = new Vector3i(renderableRegionSize.x() / 2, renderableRegionSize.y() / 2, renderableRegionSize.z() / 2);
    return new BlockRegion(cameraCoordinates).expand(renderableRegionExtents);
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion)

Example 49 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class SubSampledNoise method noise.

public float[] noise(BlockRegion region, float scale) {
    BlockRegion fullRegion = determineRequiredRegion(region);
    float[] keyData = getKeyValues(fullRegion, scale);
    float[] fullData = mapExpand(keyData, fullRegion);
    return getSubset(fullData, fullRegion, region);
}
Also used : BlockRegion(org.terasology.engine.world.block.BlockRegion)

Example 50 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class ChunkRelevanceRegion method reviewRelevantChunks.

private void reviewRelevantChunks(Vector3ic distance) {
    Vector3i extents = new Vector3i(distance.x() / 2, distance.y() / 2, distance.z() / 2);
    BlockRegion retainRegion = new BlockRegion(center).expand(extents);
    Iterator<Vector3ic> iter = relevantChunks.iterator();
    while (iter.hasNext()) {
        Vector3ic pos = iter.next();
        if (!retainRegion.contains(pos)) {
            sendChunkIrrelevant(pos);
            iter.remove();
        }
    }
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion)

Aggregations

BlockRegion (org.terasology.engine.world.block.BlockRegion)52 Vector3i (org.joml.Vector3i)29 Vector3ic (org.joml.Vector3ic)26 Test (org.junit.jupiter.api.Test)26 Chunk (org.terasology.engine.world.chunks.Chunk)23 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)11 ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)7 ChunkViewCore (org.terasology.engine.world.internal.ChunkViewCore)5 Vector3f (org.joml.Vector3f)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)4 Border3D (org.terasology.engine.world.generation.Border3D)4 WorldGeneratorPluginLibrary (org.terasology.engine.world.generator.plugin.WorldGeneratorPluginLibrary)4 ElevationFacet (org.terasology.engine.world.generation.facets.ElevationFacet)3 Vector2ic (org.joml.Vector2ic)2 RenderableChunk (org.terasology.engine.world.chunks.RenderableChunk)2 PreLodChunk (org.terasology.engine.world.chunks.internal.PreLodChunk)2 Region (org.terasology.engine.world.generation.Region)2 World (org.terasology.engine.world.generation.World)2 JsonElement (com.google.gson.JsonElement)1