pub fn extract<V>(
        &self,
        subgrid: Grid,
        mut extractor: impl FnMut(Option<BlockIndex>, &SpaceBlockData, PackedLight) -> V,
    ) -> GridArray<V> {
        GridArray::from_fn(subgrid, |cube| {
            // TODO: Implement an iterator over the indexes (which is not just
            // interior_iter().enumerate() because it's a sub-grid).
            match self.grid.index(cube) {
                Some(cube_index) => {
                    let block_index = self.contents[cube_index];
                    extractor(
                        Some(block_index),
                        &self.block_data[block_index as usize],
                        match self.physics.light {
                            LightPhysics::None => PackedLight::ONE,
                            LightPhysics::Rays { .. } => self.lighting[cube_index],
                        },
                    )
                }
                None => extractor(None, &SpaceBlockData::NOTHING, self.packed_sky_color),
            }
        })
    }
/// Copy data out of a portion of the space in a caller-chosen format.
///
/// If the provided [`Grid`] contains portions outside of this space's grid,
/// those positions in the output will be treated as if they are filled with [`AIR`]
/// and lit by [`SpacePhysics::sky_color`].
Copy data out of a portion of the space in a caller-chosen format.
Copy data out of a portion of the space in a caller - chosen format .
pub fn extract<V>(
        &self,
        subgrid: Grid,
        mut extractor: impl FnMut(Option<BlockIndex>, &SpaceBlockData, PackedLight) -> V,
    ) -> GridArray<V> {
        GridArray::from_fn(subgrid, |cube| {
            // TODO: Implement an iterator over the indexes (which is not just
            // interior_iter().enumerate() because it's a sub-grid).
            match self.grid.index(cube) {
                Some(cube_index) => {
                    let block_index = self.contents[cube_index];
                    extractor(
                        Some(block_index),
                        &self.block_data[block_index as usize],
                        match self.physics.light {
                            LightPhysics::None => PackedLight::ONE,
                            LightPhysics::Rays { .. } => self.lighting[cube_index],
                        },
                    )
                }
                None => extractor(None, &SpaceBlockData::NOTHING, self.packed_sky_color),
            }
        })
    }
pub fn extract < V > ( & self , subgrid : Grid , mut extractor : impl FnMut ( Option < BlockIndex > , & SpaceBlockData , PackedLight ) -> V , ) -> GridArray < V > { GridArray :: from_fn ( subgrid , | cube | { // TODO: Implement an iterator over the indexes (which is not just // interior_iter().enumerate() because it's a sub-grid). match self . grid . index ( cube ) { Some ( cube_index ) => { let block_index = self . contents [ cube_index ] ; extractor ( Some ( block_index ) , & self . block_data [ block_index as usize ] , match self . physics . light { LightPhysics :: None => PackedLight :: ONE , LightPhysics :: Rays { .. } => self . lighting [ cube_index ] , } , ) } None => extractor ( None , & SpaceBlockData :: NOTHING , self . packed_sky_color ) , } } ) }
Copy data out of a portion of the space in a caller-chosen format.
Copy data out of a portion of the space in a caller - chosen format .
&self
subgrid
Grid
extractor
impl FnMut(Option<BlockIndex>, &SpaceBlockData, PackedLight) -> V