pub trait Scene: Sync + Send {
// Required methods
fn new() -> Self
where Self: Sized;
fn background(&self, ray: &Ray) -> F3;
fn closest_hit(
&self,
ray: &Ray,
state: &mut State,
light: &mut LightSampleRec,
) -> bool;
fn any_hit(&self, ray: &Ray, max_dist: F) -> bool;
fn camera(&self) -> &Box<dyn Camera3D>;
fn number_of_lights(&self) -> usize;
fn light_at(&self, index: usize) -> &AnalyticalLight;
fn as_any(&mut self) -> &mut dyn Any;
// Provided methods
fn recursion_depth(&self) -> u16 { ... }
fn to_linear(&self, c: F3) -> F3 { ... }
fn sample_lights(
&self,
ray: &Ray,
state: &mut State,
light_sample: &mut LightSampleRec,
lights: &Vec<AnalyticalLight>,
) -> bool { ... }
}
Expand description
A trait based scene abstraction.
Required Methods§
fn new() -> Selfwhere
Self: Sized,
Sourcefn background(&self, ray: &Ray) -> F3
fn background(&self, ray: &Ray) -> F3
Background color for the given ray
Sourcefn closest_hit(
&self,
ray: &Ray,
state: &mut State,
light: &mut LightSampleRec,
) -> bool
fn closest_hit( &self, ray: &Ray, state: &mut State, light: &mut LightSampleRec, ) -> bool
Closest hit should return the state.hit_dist, state.normal and fill out the state.material as needed
Sourcefn number_of_lights(&self) -> usize
fn number_of_lights(&self) -> usize
Return the number of lights in the scene
Sourcefn light_at(&self, index: usize) -> &AnalyticalLight
fn light_at(&self, index: usize) -> &AnalyticalLight
Return a reference for the light at the given index
fn as_any(&mut self) -> &mut dyn Any
Provided Methods§
Sourcefn recursion_depth(&self) -> u16
fn recursion_depth(&self) -> u16
The recursion depth for the path tracer