Search in sources :

Example 76 with Vector3i

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

the class BetweenChunkPropagationTest method testBetweenChunksSimple.

@Test
public void testBetweenChunksSimple() {
    Chunk topChunk = new ChunkImpl(new Vector3i(0, 1, 0), blockManager, extraDataManager);
    Chunk bottomChunk = new ChunkImpl(new Vector3i(0, 0, 0), blockManager, extraDataManager);
    provider.addChunk(topChunk);
    provider.addChunk(bottomChunk);
    for (Vector3ic pos : new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, 1, Chunks.SIZE_Z)) {
        topChunk.setSunlight(pos, Chunks.MAX_SUNLIGHT);
        topChunk.setSunlightRegen(pos, Chunks.MAX_SUNLIGHT_REGEN);
    }
    InternalLightProcessor.generateInternalLighting(bottomChunk);
    propagator.propagateBetween(topChunk, bottomChunk, Side.BOTTOM, true);
    propagator.process();
    sunlightPropagator.process();
    for (Vector3ic pos : Chunks.CHUNK_REGION) {
        assertEquals(Chunks.MAX_SUNLIGHT, bottomChunk.getSunlight(pos), () -> "Incorrect at position " + pos);
        assertEquals(Chunks.MAX_SUNLIGHT_REGEN, bottomChunk.getSunlightRegen(pos), () -> "Incorrect at position " + pos);
    }
}
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 77 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 78 with Vector3i

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

the class Diamond3iIteratorTest method testTwoDistanceIteration.

@Test
public void testTwoDistanceIteration() {
    int cc = 0;
    for (Vector3ic next : Diamond3iIterable.region(new Vector3i(), 2).build()) {
        assertTrue(next.gridDistance(new Vector3i()) <= 2);
        cc++;
    }
    assertEquals(25, cc);
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 79 with Vector3i

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

the class Diamond3iIteratorTest method testOneDistanceIteration.

@Test
public void testOneDistanceIteration() {
    Iterator<Vector3ic> iter = Diamond3iIterable.region(new Vector3i(), 1).build().iterator();
    Set<Vector3i> expected = Sets.newHashSet(new Vector3i(), new Vector3i(1, 0, 0), new Vector3i(-1, 0, 0), new Vector3i(0, 1, 0), new Vector3i(0, -1, 0), new Vector3i(0, 0, 1), new Vector3i(0, 0, -1));
    while (iter.hasNext()) {
        Vector3i next = new Vector3i(iter.next());
        assertTrue(expected.remove(next), () -> "Received Unexpected: " + next);
    }
    assertTrue(expected.isEmpty(), () -> "Missing: " + expected);
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 80 with Vector3i

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

the class Diamond3iIteratorTest method testThreeDistanceOnlyIteration.

@Test
public void testThreeDistanceOnlyIteration() {
    int cc = 0;
    for (Vector3ic next : Diamond3iIterable.shell(new Vector3i(), 3).build()) {
        assertEquals(3, next.gridDistance(new Vector3i()));
        cc++;
    }
    assertEquals(38, cc);
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) 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