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,5 +1,5 @@
use super::ExampleScene;
use crate::basic_scene::BasicScene;
use crate::{basic_scene::BasicScene, examples::ExampleSceneEnum};
use ray_tracing_core::prelude::*;
use std::cell::{Cell, OnceCell};
@ -17,28 +17,33 @@ impl<M> SphereScene<M> {
}
}
impl<R: Rng + 'static, M: Material<R> + Clone + 'static> ExampleScene<R> for SphereScene<M> {
fn get_scene(&self) -> Box<dyn ray_tracing_core::scene::Scene<R> + Sync> {
let s = self
.scene
.get_or_init(|| BasicScene::new(self.material.take().unwrap()));
// impl<R, M> ExampleScene<R> for SphereScene<M>
// where
// R: Rng + 'static,
// M: Material<R> + Clone + 'static,
// M: Send + Sync,
// {
// fn get_scene(&self) -> ExampleSceneEnum<R> {
// let s = self
// .scene
// .get_or_init(|| BasicScene::new(self.material.take().unwrap()));
Box::new(s.clone())
}
// ExampleSceneEnum::BasicScene(s.clone())
// }
fn get_camera_pos(&self) -> Pos3 {
Pos3::new(5.0, 1.0, 0.0)
}
// fn get_camera_pos(&self) -> Pos3 {
// Pos3::new(5.0, 1.0, 0.0)
// }
fn get_camera_look_at(&self) -> Pos3 {
Pos3::new(0.0, 0.0, 0.0)
}
// fn get_camera_look_at(&self) -> Pos3 {
// Pos3::new(0.0, 0.0, 0.0)
// }
fn get_camera_up(&self) -> Dir3 {
Dir3::up()
}
// fn get_camera_up(&self) -> Dir3 {
// Dir3::up()
// }
fn get_horizontal_fov(&self) -> Float {
Float::to_radians(90.0)
}
}
// fn get_horizontal_fov(&self) -> Float {
// Float::to_radians(90.0)
// }
// }