use of org.terasology.engine.world.propagation.SingleChunkView in project Terasology by MovingBlocks.
the class InternalLightProcessor method populateSunlight.
/**
* Propagate the initial sunlight values out
*
* @param chunk The chunk to set in
*/
private static void populateSunlight(Chunk chunk, int scale) {
PropagationRules sunlightRules = new SunlightPropagationRules(chunk);
BatchPropagator lightPropagator = new StandardBatchPropagator(sunlightRules, new SingleChunkView(sunlightRules, chunk), scale);
Vector3i pos = new Vector3i();
for (int x = 0; x < Chunks.SIZE_X; x++) {
for (int z = 0; z < Chunks.SIZE_Z; z++) {
/* Start at the bottom of the chunk and then move up until the max sunlight level */
for (int y = 0; y < Chunks.SIZE_Y; y++) {
pos.set(x, y, z);
Block block = chunk.getBlock(x, y, z);
byte light = sunlightRules.getFixedValue(block, pos);
if (light > 0) {
chunk.setSunlight(x, y, z, light);
lightPropagator.propagateFrom(pos, light);
}
}
}
}
lightPropagator.process();
}
use of org.terasology.engine.world.propagation.SingleChunkView in project Terasology by MovingBlocks.
the class InternalLightProcessor method populateLight.
/**
* Propagate out light from the initial luminous blocks
*
* @param chunk The chunk to populate through
*/
private static void populateLight(Chunk chunk, int scale) {
BatchPropagator lightPropagator = new StandardBatchPropagator(LIGHT_RULES, new SingleChunkView(LIGHT_RULES, chunk), scale);
Vector3i pos = new Vector3i();
for (int x = 0; x < Chunks.SIZE_X; x++) {
for (int z = 0; z < Chunks.SIZE_Z; z++) {
for (int y = 0; y < Chunks.SIZE_Y; y++) {
Block block = chunk.getBlock(x, y, z);
if (block.getLuminance() > 0) {
chunk.setLight(x, y, z, block.getLuminance());
lightPropagator.propagateFrom(pos.set(x, y, z), block.getLuminance());
}
}
}
}
lightPropagator.process();
}
Aggregations