Search in sources :

Example 16 with Vector3i

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

the class BulkLightPropagationTest method testAddOverlappingLights.

@Test
public void testAddOverlappingLights() {
    Vector3i lightPos = new Vector3i(5, 0, 0);
    StubPropagatorWorldView worldView = new StubPropagatorWorldView(Chunks.CHUNK_REGION, air);
    worldView.setBlockAt(new Vector3i(0, 0, 0), fullLight);
    worldView.setBlockAt(lightPos, fullLight);
    BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
    propagator.process(new BlockChange(ZERO_VECTOR, air, fullLight), new BlockChange(lightPos, air, fullLight));
    assertEquals(fullLight.getLuminance(), worldView.getValueAt(new Vector3i(0, 0, 0)));
    assertEquals(fullLight.getLuminance() - 1, worldView.getValueAt(new Vector3i(1, 0, 0)));
    assertEquals(fullLight.getLuminance() - 2, worldView.getValueAt(new Vector3i(2, 0, 0)));
    assertEquals(fullLight.getLuminance() - 2, worldView.getValueAt(new Vector3i(3, 0, 0)));
    assertEquals(fullLight.getLuminance() - 1, worldView.getValueAt(new Vector3i(4, 0, 0)));
    assertEquals(fullLight.getLuminance(), worldView.getValueAt(new Vector3i(5, 0, 0)));
}
Also used : Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 17 with Vector3i

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

the class BulkLightPropagationTest method testReduceLight.

@Test
public void testReduceLight() {
    StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion, air);
    worldView.setBlockAt(new Vector3i(0, 0, 0), fullLight);
    BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
    propagator.process(new BlockChange(ZERO_VECTOR, air, fullLight));
    worldView.setBlockAt(new Vector3i(0, 0, 0), weakLight);
    propagator.process(new BlockChange(ZERO_VECTOR, fullLight, weakLight));
    assertEquals(weakLight.getLuminance(), worldView.getValueAt(new Vector3i(0, 0, 0)));
    for (int i = 1; i < 15; ++i) {
        byte expectedLuminance = (byte) Math.max(0, weakLight.getLuminance() - i);
        for (Vector3ic pos : Diamond3iIterable.shell(new Vector3i(0, 0, 0), i).build()) {
            assertEquals(expectedLuminance, worldView.getValueAt(pos));
        }
    }
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 18 with Vector3i

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

the class BulkLightPropagationTest method testAddLightInLight.

@Test
public void testAddLightInLight() {
    StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion, air);
    worldView.setBlockAt(new Vector3i(2, 0, 0), mediumLight);
    BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
    propagator.process(new BlockChange(new Vector3i(2, 0, 0), air, mediumLight));
    worldView.setBlockAt(new Vector3i(0, 0, 0), fullLight);
    propagator.process(new BlockChange(ZERO_VECTOR, air, fullLight));
    for (int i = 0; i < fullLight.getLuminance() + 1; ++i) {
        byte expectedLuminance = (byte) Math.max(0, fullLight.getLuminance() - i);
        for (Vector3ic pos : Diamond3iIterable.shell(new Vector3i(0, 0, 0), i).build()) {
            assertEquals(expectedLuminance, worldView.getValueAt(pos));
        }
    }
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 19 with Vector3i

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

the class BulkLightPropagationTest method testAddWeakLightNextToStrongLight.

@Test
public void testAddWeakLightNextToStrongLight() {
    StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion, air);
    worldView.setBlockAt(new Vector3i(0, 0, 0), fullLight);
    BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
    propagator.process(new BlockChange(ZERO_VECTOR, air, fullLight));
    worldView.setBlockAt(new Vector3i(1, 0, 0), weakLight);
    propagator.process(new BlockChange(new Vector3i(1, 0, 0), air, weakLight));
    assertEquals(14, worldView.getValueAt(new Vector3i(1, 0, 0)));
}
Also used : Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 20 with Vector3i

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

the class BulkLightPropagationTest method testRemoveLightInVacuum.

@Test
public void testRemoveLightInVacuum() {
    StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion, air);
    worldView.setBlockAt(new Vector3i(0, 0, 0), fullLight);
    BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
    propagator.process(new BlockChange(ZERO_VECTOR, air, fullLight));
    worldView.setBlockAt(new Vector3i(0, 0, 0), air);
    propagator.process(new BlockChange(ZERO_VECTOR, fullLight, air));
    assertEquals(0, worldView.getValueAt(new Vector3i(0, 0, 0)));
    for (int i = 1; i < fullLight.getLuminance(); ++i) {
        for (Vector3ic pos : Diamond3iIterable.shell(new Vector3i(0, 0, 0), i).build()) {
            assertEquals(0, worldView.getValueAt(pos));
        }
    }
}
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