Change testscene interface

This commit is contained in:
hal8174 2025-01-02 23:17:17 +01:00
parent 829476c602
commit 0b3daf9441
12 changed files with 313 additions and 223 deletions

View file

@ -4,6 +4,7 @@ use ray_tracing_core::{
scene::{Intersection, LightSample, Scene},
};
use sampling::sample_triangle;
use std::sync::Arc;
type Index = u32;
@ -11,11 +12,23 @@ type Index = u32;
pub struct TriangleBVH<R: Rng> {
vertices: Vec<Pos3>,
triangles: Vec<Triangle>,
materials: Vec<BVHMaterial<R>>,
materials: Arc<[BVHMaterial<R>]>,
bvh: Vec<Node>,
lights: Vec<Triangle>,
}
impl<R: Rng> Clone for TriangleBVH<R> {
fn clone(&self) -> Self {
Self {
vertices: self.vertices.clone(),
triangles: self.triangles.clone(),
materials: Arc::clone(&self.materials),
bvh: self.bvh.clone(),
lights: self.lights.clone(),
}
}
}
#[derive(Debug)]
pub struct BVHMaterial<R: Rng> {
pub material: Option<Box<dyn Material<R>>>,
@ -223,7 +236,7 @@ impl<R: Rng> TriangleBVH<R> {
vertices,
bvh,
triangles,
materials,
materials: materials.into(),
lights,
}
}