Search in sources :

Example 6 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BulkSunlightPropagationTest method testStopSunlightVertical.

@Test
public void testStopSunlightVertical() {
    for (Vector3ic pos : new BlockRegion(0, 16, 0).union(Chunks.SIZE_X - 1, Chunks.SIZE_Y - 1, Chunks.SIZE_Z - 1)) {
        regenWorldView.setValueAt(pos, Chunks.MAX_SUNLIGHT_REGEN);
        lightWorldView.setValueAt(pos, Chunks.MAX_SUNLIGHT);
    }
    for (Vector3ic pos : new BlockRegion(0, 15, 0).union(Chunks.SIZE_X - 1, 15, Chunks.SIZE_Z - 1)) {
        regenWorldView.setBlockAt(new Vector3i(pos), solid);
    }
    for (Vector3ic pos : new BlockRegion(0, 0, 0).union(Chunks.SIZE_X - 1, 14, Chunks.SIZE_Z - 1)) {
        regenWorldView.setValueAt(pos, (byte) (14 - pos.y()));
    }
    regenWorldView.setBlockAt(new Vector3i(16, 15, 16), air);
    propagator.process(new BlockChange(new Vector3i(16, 15, 16), solid, air));
    sunlightPropagator.process(new BlockChange(new Vector3i(16, 15, 16), solid, air));
    regenWorldView.setBlockAt(new Vector3i(16, 15, 16), solid);
    propagator.process(new BlockChange(new Vector3i(16, 15, 16), air, solid));
    sunlightPropagator.process(new BlockChange(new Vector3i(16, 15, 16), air, solid));
    for (Vector3ic pos : new BlockRegion(0, 0, 0).union(Chunks.SIZE_X - 1, 15, Chunks.SIZE_Z - 1)) {
        assertEquals(Math.max(0, 14 - pos.y()), regenWorldView.getValueAt(pos), "Incorrect value at " + pos);
        assertEquals(0, lightWorldView.getValueAt(pos), "Incorrect value at " + pos);
    }
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) Test(org.junit.jupiter.api.Test)

Example 7 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class SparseFieldFacetTest method testGetRelativeMap.

@Test
public void testGetRelativeMap() {
    facet.set(0, 1, 2, 4f);
    facet.set(0, 1, 3, 3);
    facet.set(9, 3, 1, Math.PI);
    facet.setWorld(13, 28, 34, 2);
    facet.setWorld(10, 21, 35, 1);
    Map<Vector3i, Number> expected = ImmutableMap.<Vector3i, Number>of(new Vector3i(0, 1, 2), 4.0f, new Vector3i(0, 1, 3), 3.0f, new Vector3i(3, 8, 4), 2.0f, new Vector3i(0, 1, 5), 1.0f, new Vector3i(9, 3, 1), Math.PI);
    assertEquals(expected, facet.getRelativeEntries());
}
Also used : Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 8 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class InternalLightGeneratorTest method testLightPropagation.

@Test
public void testLightPropagation() {
    Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
    chunk.setBlock(16, 32, 16, fullLight);
    InternalLightProcessor.generateInternalLighting(chunk);
    assertEquals(fullLight.getLuminance(), chunk.getLight(16, 32, 16));
    assertEquals(fullLight.getLuminance() - 1, chunk.getLight(16, 33, 16));
    for (int i = 1; i < fullLight.getLuminance(); ++i) {
        for (Vector3ic pos : Diamond3iIterable.shell(new Vector3i(16, 32, 16), i).build()) {
            assertEquals(fullLight.getLuminance() - i, chunk.getLight(pos));
        }
    }
}
Also used : ChunkImpl(org.terasology.engine.world.chunks.internal.ChunkImpl) Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) Chunk(org.terasology.engine.world.chunks.Chunk) Test(org.junit.jupiter.api.Test)

Example 9 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class InternalLightGeneratorTest method testHorizontalSunlightPropagation.

@Test
public void testHorizontalSunlightPropagation() {
    Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
    for (Vector3ic pos : new BlockRegion(0, 4, 0).setSize(Chunks.SIZE_X, 1, Chunks.SIZE_Z)) {
        chunk.setBlock(pos, solidBlock);
    }
    chunk.setBlock(new Vector3i(16, 4, 16), airBlock);
    InternalLightProcessor.generateInternalLighting(chunk);
    assertEquals(12, chunk.getSunlight(16, 3, 16));
    assertEquals(11, chunk.getSunlight(15, 3, 16));
    assertEquals(11, chunk.getSunlight(17, 3, 16));
    assertEquals(11, chunk.getSunlight(16, 3, 15));
    assertEquals(11, chunk.getSunlight(16, 3, 17));
    assertEquals(12, chunk.getSunlight(15, 2, 16));
    assertEquals(12, chunk.getSunlight(17, 2, 16));
    assertEquals(12, chunk.getSunlight(16, 2, 15));
    assertEquals(12, chunk.getSunlight(16, 2, 17));
}
Also used : ChunkImpl(org.terasology.engine.world.chunks.internal.ChunkImpl) Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk) Test(org.junit.jupiter.api.Test)

Example 10 with Vector3i

use of org.joml.Vector3i 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));
}
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)

Aggregations

Vector3i (org.joml.Vector3i)203 Test (org.junit.jupiter.api.Test)87 Vector3ic (org.joml.Vector3ic)54 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)38 Chunk (org.terasology.engine.world.chunks.Chunk)36 BlockRegion (org.terasology.engine.world.block.BlockRegion)30 Block (org.terasology.engine.world.block.Block)22 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)21 Vector3f (org.joml.Vector3f)19 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Map (java.util.Map)11 BeforeEach (org.junit.jupiter.api.BeforeEach)10 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)10 ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)8 OnChunkLoaded (org.terasology.engine.world.chunks.event.OnChunkLoaded)7 Lists (com.google.common.collect.Lists)6 Maps (com.google.common.collect.Maps)6 List (java.util.List)6 ExecutionException (java.util.concurrent.ExecutionException)6 Future (java.util.concurrent.Future)6