Change Scene trait to account for material data

This commit is contained in:
hal8174 2025-08-22 21:48:07 +02:00
parent 76448ed442
commit 2bc5ec93fe
Signed by: hal8174
SSH key fingerprint: SHA256:NN98ZYwnrreQLSOV/g+amY7C3yL/mS1heD7bi5t6PPw
19 changed files with 306 additions and 124 deletions

View file

@ -1,6 +1,9 @@
use std::cell::OnceCell;
use crate::triangle_bvh::{BVHMaterial, Triangle, TriangleBVH};
use crate::{
examples::ExampleSceneEnum,
triangle_bvh::{BVHMaterial, Triangle, TriangleBVH},
};
use super::ExampleScene;
@ -26,7 +29,7 @@ impl<R: Rng> Default for BasicCornell<R> {
}
impl<R: Rng + 'static> ExampleScene<R> for BasicCornell<R> {
fn get_scene(&self) -> Box<dyn Scene<R> + Sync> {
fn get_scene(&self) -> ExampleSceneEnum<R> {
let s = self.scene.get_or_init(|| {
let side_length = 1.5;
let light_size = 0.5;
@ -95,7 +98,7 @@ impl<R: Rng + 'static> ExampleScene<R> for BasicCornell<R> {
)
});
Box::new(s.clone()) as Box<dyn Scene<R> + Sync>
ExampleSceneEnum::TriangleBVH(s.clone())
}
fn get_camera_pos(&self) -> Pos3 {