Trait Scene

Source
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§

Source

fn new() -> Self
where Self: Sized,

Source

fn background(&self, ray: &Ray) -> F3

Background color for the given ray

Source

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

Source

fn any_hit(&self, ray: &Ray, max_dist: F) -> bool

Used for shadow rays.

Source

fn camera(&self) -> &Box<dyn Camera3D>

Return the camera for the scene

Source

fn number_of_lights(&self) -> usize

Return the number of lights in the scene

Source

fn light_at(&self, index: usize) -> &AnalyticalLight

Return a reference for the light at the given index

Source

fn as_any(&mut self) -> &mut dyn Any

Provided Methods§

Source

fn recursion_depth(&self) -> u16

The recursion depth for the path tracer

Source

fn to_linear(&self, c: F3) -> F3

Source

fn sample_lights( &self, ray: &Ray, state: &mut State, light_sample: &mut LightSampleRec, lights: &Vec<AnalyticalLight>, ) -> bool

Implementors§