use of org.joml.Vector3ic 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.Vector3ic 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.Vector3ic 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));
}
}
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class BulkLightPropagationTest method testRemoveSolidAllowsLight.
@Test
public void testRemoveSolidAllowsLight() {
StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion, air);
for (Vector3ic pos : new BlockRegion(1, 0, 0).expand(0, 30, 30)) {
worldView.setBlockAt(new Vector3i(pos), solid);
}
worldView.setBlockAt(new Vector3i(0, 0, 0), fullLight);
BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
propagator.process(new BlockChange(ZERO_VECTOR, air, fullLight));
assertEquals(0, worldView.getValueAt(new Vector3i(1, 0, 0)));
worldView.setBlockAt(new Vector3i(1, 0, 0), air);
propagator.process(new BlockChange(new Vector3i(1, 0, 0), solid, air));
assertEquals(14, worldView.getValueAt(new Vector3i(1, 0, 0)));
assertEquals(13, worldView.getValueAt(new Vector3i(2, 0, 0)));
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class BlockRegionTest method testBoxOfBlocksRegion.
@Test
public void testBoxOfBlocksRegion() {
BlockRegion region = new BlockRegion(new Vector3i(0, 0, 0), new Vector3i(1, 1, 1));
List<Vector3ic> actual = new ArrayList<>();
for (Vector3ic vector3ic : region) {
actual.add(new Vector3i(vector3ic));
}
Assertions.assertEquals(8, actual.size());
Assertions.assertEquals(new HashSet<>(expectedPositions(region)), new HashSet<>(actual));
}
Aggregations