fn opaque_non_emitting_creation(
    context: &mut Context,
    chunk_lights: &ChunkLights,
    position: BlockPosition,
    new_block: Block,
) {
    // Re-calculate all lights that could have affected this block.
    // We ensure that all areas are correctly set to dark by first
    // faking that the block was never created.
    context.set_block_at(position, Block::Air);

    let nearby_lights = chunk_lights.lights_within_distance(position, MAX_TRAVEL_DISTANCE);

    nearby_lights.iter().for_each(|light| {
        let block = context.block_at(*light);
        emitting_removal(context, chunk_lights, *light, block);
    });

    // Set block back to correct value.
    context.set_block_at(position, new_block);

    // Recalculate nearby lights.
    nearby_lights.iter().for_each(|light| {
        emitting_creation(context, *light);
    });
}
/// Algorithm #3, as described in the module-level docs.
Algorithm #3, as described in the module-level docs.
Algorithm #3 as described in the module - level docs .
fn opaque_non_emitting_creation(
    context: &mut Context,
    chunk_lights: &ChunkLights,
    position: BlockPosition,
    new_block: Block,
) {
    // Re-calculate all lights that could have affected this block.
    // We ensure that all areas are correctly set to dark by first
    // faking that the block was never created.
    context.set_block_at(position, Block::Air);
    let nearby_lights = chunk_lights.lights_within_distance(position, MAX_TRAVEL_DISTANCE);
    nearby_lights.iter().for_each(|light| {
        let block = context.block_at(*light);
        emitting_removal(context, chunk_lights, *light, block);
    });
    // Set block back to correct value.
    context.set_block_at(position, new_block);
    // Recalculate nearby lights.
    nearby_lights.iter().for_each(|light| {
        emitting_creation(context, *light);
    });
}
fn opaque_non_emitting_creation ( context : & mut Context , chunk_lights : & ChunkLights , position : BlockPosition , new_block : Block , ) { // Re-calculate all lights that could have affected this block. // We ensure that all areas are correctly set to dark by first // faking that the block was never created. context . set_block_at ( position , Block :: Air ) ; let nearby_lights = chunk_lights . lights_within_distance ( position , MAX_TRAVEL_DISTANCE ) ; nearby_lights . iter ( ) . for_each ( | light | { let block = context . block_at ( * light ) ; emitting_removal ( context , chunk_lights , * light , block ) ; } ) ; // Set block back to correct value. context . set_block_at ( position , new_block ) ; // Recalculate nearby lights. nearby_lights . iter ( ) . for_each ( | light | { emitting_creation ( context , * light ) ; } ) ; }
Algorithm #3, as described in the module-level docs.
Algorithm #3 as described in the module - level docs .
context
&mut Context
chunk_lights
&ChunkLights
position
BlockPosition
new_block
Block
context
&mut Context
chunk_lights
&ChunkLights
position
BlockPosition
new_block
Block