use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class BulkLightPropagationTest method testRemoveAdjacentLights.
@Test
public void testRemoveAdjacentLights() {
StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion, air);
worldView.setBlockAt(new Vector3i(1, 0, 0), mediumLight);
worldView.setBlockAt(new Vector3i(0, 0, 0), mediumLight);
BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
propagator.process(new BlockChange(new Vector3i(1, 0, 0), air, mediumLight), new BlockChange(ZERO_VECTOR, air, mediumLight));
worldView.setBlockAt(new Vector3i(1, 0, 0), air);
worldView.setBlockAt(new Vector3i(0, 0, 0), air);
propagator.process(new BlockChange(new Vector3i(1, 0, 0), mediumLight, air), new BlockChange(ZERO_VECTOR, mediumLight, air));
for (int i = 0; i < fullLight.getLuminance() + 1; ++i) {
byte expectedLuminance = (byte) 0;
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 testRemoveLightOverlappingAtEdge.
@Test
public void testRemoveLightOverlappingAtEdge() {
Vector3i lightPos = new Vector3i(2, 0, 0);
StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion, air);
worldView.setBlockAt(new Vector3i(0, 0, 0), weakLight);
worldView.setBlockAt(lightPos, weakLight);
BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
propagator.process(new BlockChange(ZERO_VECTOR, air, weakLight), new BlockChange(lightPos, air, weakLight));
worldView.setBlockAt(lightPos, air);
propagator.process(new BlockChange(lightPos, weakLight, air));
for (int i = 0; i < weakLight.getLuminance() + 1; ++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 testRemoveSolidAndLight.
@Test
public void testRemoveSolidAndLight() {
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);
worldView.setBlockAt(new Vector3i(0, 0, 0), air);
propagator.process(new BlockChange(new Vector3i(1, 0, 0), solid, air), new BlockChange(ZERO_VECTOR, fullLight, air));
for (int i = 0; i < fullLight.getLuminance() + 1; ++i) {
byte expectedLuminance = (byte) 0;
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 BetweenChunkPropagationTest method testBetweenChunksSimpleSunlightRegenOnly.
@Test
public void testBetweenChunksSimpleSunlightRegenOnly() {
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();
for (Vector3ic pos : Chunks.CHUNK_REGION) {
assertEquals(Chunks.MAX_SUNLIGHT_REGEN, bottomChunk.getSunlightRegen(pos), () -> "Incorrect at position " + pos);
}
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class BulkSunlightPropagationTest method setup.
@BeforeEach
public void setup() throws Exception {
super.setup();
regenRules = new SunlightRegenPropagationRules();
AssetManager assetManager = CoreRegistry.get(AssetManager.class);
blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
CoreRegistry.put(BlockManager.class, blockManager);
BlockFamilyDefinitionData solidData = new BlockFamilyDefinitionData();
solidData.getBaseSection().setDisplayName("Stone");
solidData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
solidData.getBaseSection().setTranslucent(false);
solidData.setBlockFamily(SymmetricFamily.class);
assetManager.loadAsset(new ResourceUrn("engine:stone"), solidData, BlockFamilyDefinition.class);
solid = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
air = blockManager.getBlock(BlockManager.AIR_ID);
Map<Vector3ic, Block> blockData = Maps.newHashMap();
regenWorldView = new StubPropagatorWorldView(Chunks.CHUNK_REGION, air, blockData);
lightWorldView = new StubPropagatorWorldView(Chunks.CHUNK_REGION, air, blockData);
lightRules = new SunlightPropagationRules(regenWorldView);
sunlightPropagator = new StandardBatchPropagator(lightRules, lightWorldView);
propagator = new SunlightRegenBatchPropagator(regenRules, regenWorldView, sunlightPropagator, lightWorldView);
}
Aggregations