use super::implementation::algorithm::Extractor;
use super::structs::*;
use super::{
density::*,
voxel_source::{VoxelSource, WorldMappingVoxelSource},
};
use crate::transition_sides::TransitionSides;
pub fn extract<D, S>(
source: S,
block: &Block,
threshold: D,
transition_sides: TransitionSides,
) -> Mesh
where
D: Density,
S: VoxelSource<D>,
{
Extractor::new(source, block, threshold, transition_sides).extract()
}
pub fn extract_from_field<D, F>(
field: F,
block: &Block,
threshold: D,
transition_sides: TransitionSides,
) -> Mesh
where
D: Density,
F: ScalarField<D>,
{
let mut source = WorldMappingVoxelSource { field, block };
Extractor::new(&mut source, block, threshold, transition_sides).extract()
}
pub fn extract_from_fn<D, F>(
f: F,
block: &Block,
threshold: D,
transition_sides: TransitionSides,
) -> Mesh
where
D: Density,
F: FnMut(f32, f32, f32) -> D,
{
let field = ScalarFieldForFn(f);
let mut source = WorldMappingVoxelSource { field, block };
Extractor::new(&mut source, block, threshold, transition_sides).extract()
}