Search in sources :

Example 1 with SingleChunkView

use of org.terasology.world.propagation.SingleChunkView in project Terasology by MovingBlocks.

the class InternalLightProcessor method populateSunlight.

private static void populateSunlight(LitChunk chunk) {
    PropagationRules sunlightRules = new SunlightPropagationRules(chunk);
    BatchPropagator lightPropagator = new StandardBatchPropagator(sunlightRules, new SingleChunkView(sunlightRules, chunk));
    for (int x = 0; x < ChunkConstants.SIZE_X; x++) {
        for (int z = 0; z < ChunkConstants.SIZE_Z; z++) {
            for (int y = 0; y < ChunkConstants.MAX_SUNLIGHT; ++y) {
                Vector3i pos = new Vector3i(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();
}
Also used : StandardBatchPropagator(org.terasology.world.propagation.StandardBatchPropagator) StandardBatchPropagator(org.terasology.world.propagation.StandardBatchPropagator) BatchPropagator(org.terasology.world.propagation.BatchPropagator) Vector3i(org.terasology.math.geom.Vector3i) Block(org.terasology.world.block.Block) PropagationRules(org.terasology.world.propagation.PropagationRules) SingleChunkView(org.terasology.world.propagation.SingleChunkView)

Example 2 with SingleChunkView

use of org.terasology.world.propagation.SingleChunkView in project Terasology by MovingBlocks.

the class InternalLightProcessor method populateLight.

private static void populateLight(LitChunk chunk) {
    BatchPropagator lightPropagator = new StandardBatchPropagator(LIGHT_RULES, new SingleChunkView(LIGHT_RULES, chunk));
    for (int x = 0; x < ChunkConstants.SIZE_X; x++) {
        for (int z = 0; z < ChunkConstants.SIZE_Z; z++) {
            for (int y = 0; y < ChunkConstants.SIZE_Y; y++) {
                Block block = chunk.getBlock(x, y, z);
                if (block.getLuminance() > 0) {
                    chunk.setLight(x, y, z, block.getLuminance());
                    lightPropagator.propagateFrom(new Vector3i(x, y, z), block.getLuminance());
                }
            }
        }
    }
    lightPropagator.process();
}
Also used : StandardBatchPropagator(org.terasology.world.propagation.StandardBatchPropagator) StandardBatchPropagator(org.terasology.world.propagation.StandardBatchPropagator) BatchPropagator(org.terasology.world.propagation.BatchPropagator) Vector3i(org.terasology.math.geom.Vector3i) Block(org.terasology.world.block.Block) SingleChunkView(org.terasology.world.propagation.SingleChunkView)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)2 Block (org.terasology.world.block.Block)2 BatchPropagator (org.terasology.world.propagation.BatchPropagator)2 SingleChunkView (org.terasology.world.propagation.SingleChunkView)2 StandardBatchPropagator (org.terasology.world.propagation.StandardBatchPropagator)2 PropagationRules (org.terasology.world.propagation.PropagationRules)1