use crate::sphere_tracing::ClosestHit;
use crate::sphere_tracing::Options;
use crate::Graph;
use crate::NodeId;
pub use macaw::Ray3;
pub use macaw::Vec3;
pub fn march(
graph: &Graph,
root: NodeId,
ray: Ray3,
t_range: std::ops::RangeInclusive<f32>,
opt: &Options,
) -> ClosestHit {
puffin::profile_function!();
let program = crate::compile(graph, root);
let mut sd = to_sd_func(&program);
crate::sphere_tracing::trace(&mut sd, ray, t_range, opt)
}
pub fn to_sd_func(program: &crate::Program) -> impl FnMut(Vec3) -> f32 + '_ {
let mut d_context = crate::Interpreter::new_context(&program.opcodes, &program.constants);
move |pos: Vec3| crate::Interpreter::<f32>::interpret(&mut d_context, pos).unwrap()
}