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)));
}
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));
}
}
}
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));
}
}
}
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)));
}
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));
}
}
}
Aggregations