Fix all warnings

This commit is contained in:
hal8174 2025-08-23 13:36:07 +02:00
parent 2bc5ec93fe
commit ae4dc2c21a
Signed by: hal8174
SSH key fingerprint: SHA256:NN98ZYwnrreQLSOV/g+amY7C3yL/mS1heD7bi5t6PPw
26 changed files with 249 additions and 185 deletions

View file

@ -1,14 +1,11 @@
use std::cell::OnceCell;
use super::ExampleScene;
use crate::{
examples::ExampleSceneEnum,
triangle_bvh::{BVHMaterial, Triangle, TriangleBVH},
};
use super::ExampleScene;
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
use ray_tracing_core::{light::AreaLight, prelude::*};
use ray_tracing_material::{diffuse::DiffuseMaterial, mirror::Mirror};
use std::cell::OnceCell;
pub struct BasicCornell<R: Rng> {
scene: OnceCell<TriangleBVH<R>>,

View file

@ -1,5 +1,5 @@
use rand::Rng;
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
use ray_tracing_core::{light::AreaLight, prelude::*};
use ray_tracing_material::{diffuse::DiffuseMaterial, mirror::Mirror};
use std::cell::OnceCell;

View file

@ -3,7 +3,7 @@ use crate::{
examples::ExampleSceneEnum,
triangle_bvh::{BVHMaterial, Triangle, TriangleBVH},
};
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
use ray_tracing_core::{light::AreaLight, prelude::*};
use ray_tracing_material::{
microfacet::{BeckmannDistribution, Microfacet},
mirror::Mirror,

View file

@ -1,17 +1,16 @@
use ray_tracing_core::{prelude::*, scene::Scene};
use ray_tracing_material::iridescent::Iridescent;
use ray_tracing_material::microfacet::{BeckmannDistribution, Microfacet};
use ray_tracing_material::mirror::Mirror;
use std::collections::HashMap;
use std::fmt::Debug;
use crate::acceleration_structure::triangle_bvh::TriangleBVH;
use crate::acceleration_structure::AccelerationStructureScene;
use crate::basic_scene::BasicScene;
use crate::acceleration_structure::{triangle_bvh::TriangleBVH, AccelerationStructureScene};
use ray_tracing_core::prelude::*;
use ray_tracing_material::{
iridescent::Iridescent,
microfacet::{BeckmannDistribution, Microfacet},
mirror::Mirror,
};
use std::{collections::HashMap, fmt::Debug, sync::Arc};
pub enum ExampleSceneEnum<R: Rng> {
AccelerationStructureScene(AccelerationStructureScene<TriangleBVH<u32>, R>),
TriangleBVH(crate::triangle_bvh::TriangleBVH<R>),
BasicScene(crate::basic_scene::BasicScene<Arc<dyn Material<R>>>),
}
pub trait ExampleScene<R: Rng> {
@ -59,8 +58,8 @@ pub fn example_scenes<R: Rng + Debug + 'static>() -> HashMap<&'static str, Box<d
map.insert("mis_test", Box::new(mis_test::MISTest::new()));
// let material = Iridescent::new(250.0, 250.0, 1.0, 1.3, 20);
// let material = Iridescent::new(0.9 * 988.0, 0.1 * 988.0, 1.0, 1.5, 20);
// map.insert("sphere", Box::new(sphere::SphereScene::new(material)));
let material = Iridescent::new(0.9 * 988.0, 0.1 * 988.0, 1.0, 1.5, 20);
map.insert("sphere", Box::new(sphere::SphereScene::new(material)));
map.insert(
"presentation",

View file

@ -8,7 +8,7 @@ use ray_tracing_core::{
color::Color,
light::AreaLight,
math::{Dir3, Pos3},
prelude::{Float, Material},
prelude::Float,
};
use ray_tracing_material::{iridescent::Iridescent, oren_nayar::OrenNayar};
use std::cell::OnceCell;

View file

@ -1,14 +1,17 @@
use super::ExampleScene;
use crate::{basic_scene::BasicScene, examples::ExampleSceneEnum};
use ray_tracing_core::prelude::*;
use std::cell::{Cell, OnceCell};
use std::{
cell::{Cell, OnceCell},
sync::Arc,
};
pub struct SphereScene<M> {
scene: OnceCell<BasicScene<M>>,
pub struct SphereScene<R: Rng, M> {
scene: OnceCell<BasicScene<Arc<dyn Material<R>>>>,
material: Cell<Option<M>>,
}
impl<M> SphereScene<M> {
impl<R: Rng, M> SphereScene<R, M> {
pub fn new(material: M) -> Self {
Self {
scene: OnceCell::new(),
@ -17,33 +20,33 @@ impl<M> SphereScene<M> {
}
}
// 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()));
impl<R, M> ExampleScene<R> for SphereScene<R, 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(Arc::new(self.material.take().unwrap())));
// ExampleSceneEnum::BasicScene(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)
}
}

View file

@ -1,15 +1,14 @@
use super::ExampleScene;
use crate::{
examples::ExampleSceneEnum,
parse_obj::ObjData,
triangle_bvh::{BVHMaterial, Triangle, TriangleBVH},
};
use rand::Rng;
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
use ray_tracing_core::{light::AreaLight, prelude::*};
use ray_tracing_material::oren_nayar::OrenNayar;
use std::cell::{Cell, OnceCell};
use super::ExampleScene;
pub struct StanfordDragon<R: Rng, M: Material<R>> {
scene: OnceCell<TriangleBVH<R>>,
material: Cell<Option<M>>,

View file

@ -1,11 +1,4 @@
use rand::Rng;
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
use ray_tracing_material::{
microfacet::{BeckmannDistribution, Microfacet},
oren_nayar::OrenNayar,
};
use std::cell::OnceCell;
use super::ExampleScene;
use crate::{
acceleration_structure::{
triangle_bvh::{Triangle, TriangleBVH},
@ -14,8 +7,13 @@ use crate::{
examples::ExampleSceneEnum,
parse_obj::ObjData,
};
use super::ExampleScene;
use rand::Rng;
use ray_tracing_core::{light::AreaLight, prelude::*};
use ray_tracing_material::{
microfacet::{BeckmannDistribution, Microfacet},
oren_nayar::OrenNayar,
};
use std::cell::OnceCell;
pub struct StanfordDragon<R: Rng> {
scene: OnceCell<AccelerationStructureScene<TriangleBVH<u32>, R>>,

View file

@ -69,19 +69,19 @@ fn parse_float(i: &str) -> IResult<&str, Float> {
double(i).map(|(i, f)| (i, f as Float))
}
fn parse_vertex(i: &str) -> IResult<&str, Line> {
fn parse_vertex(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
let mut v = [0.0; 3];
let (i, _) = fill(parse_float, &mut v)(i)?;
Ok((i, Line::Vertex(Pos3::new(v[0], v[1], v[2]))))
}
fn parse_normal(i: &str) -> IResult<&str, Line> {
fn parse_normal(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
let mut v = [0.0; 3];
let (i, _) = fill(parse_float, &mut v)(i)?;
Ok((i, Line::Normal(Dir3::new(v[0], v[1], v[2]))))
}
fn parse_texcoord(i: &str) -> IResult<&str, Line> {
fn parse_texcoord(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
let mut v = [0.0; 2];
let (i, _) = fill(parse_float, &mut v)(i)?;
Ok((i, Line::Texcoord(v)))
@ -125,7 +125,7 @@ fn face_vertex_normal_tex(i: &str) -> IResult<&str, (i32, i32, i32)> {
Ok((i, (v, t, n)))
}
fn parse_face(i: &str) -> IResult<&str, Line> {
fn parse_face(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
if let Ok((i, s)) = many1(face_vertex_normal_tex)(i) {
if s.len() >= 3 {
Ok((
@ -198,17 +198,17 @@ fn parse_face(i: &str) -> IResult<&str, Line> {
}
}
fn parse_mtllib(i: &str) -> IResult<&str, Line> {
fn parse_mtllib(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
let (i, s) = take_till(|c| c == ' ')(i)?;
Ok((i, Line::Mtllib(s)))
}
fn parse_mtl(i: &str) -> IResult<&str, Line> {
fn parse_mtl(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
let (i, s) = take_till(|c| c == ' ')(i)?;
Ok((i, Line::Material(s)))
}
fn parse_line(i: &str) -> IResult<&str, Line> {
fn parse_line(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
let (i, ident) = parse_identifier(i)?;
let (i, _) = remove_whitespace(i)?;
match ident {
@ -250,12 +250,12 @@ enum MaterialsLine<'a> {
Empty,
}
fn parse_new_material(i: &str) -> IResult<&str, MaterialsLine> {
fn parse_new_material(i: &'_ str) -> IResult<&'_ str, MaterialsLine<'_>> {
let (i, ident) = take_till1(|c| c == ' ')(i)?;
Ok((i, MaterialsLine::Material(ident)))
}
fn parse_line_material(i: &str) -> IResult<&str, MaterialsLine> {
fn parse_line_material(i: &'_ str) -> IResult<&'_ str, MaterialsLine<'_>> {
let (i, ident) = parse_identifier(i)?;
let (i, _) = remove_whitespace(i)?;
match ident {