diff --git a/shared/src/bxdfs/diffuse.rs b/shared/src/bxdfs/diffuse.rs index 0643b4f..70e20a0 100644 --- a/shared/src/bxdfs/diffuse.rs +++ b/shared/src/bxdfs/diffuse.rs @@ -41,7 +41,7 @@ impl BxDFTrait for DiffuseBxDF { return None; } let mut wi = sample_cosine_hemisphere(u); - if wo.z() == 0. { + if wo.z() < 0. { wi[2] *= -1.; } let pdf = cosine_hemisphere_pdf(abs_cos_theta(wi)); diff --git a/shared/src/cameras/orthographic.rs b/shared/src/cameras/orthographic.rs index 8a9ab3a..021d549 100644 --- a/shared/src/cameras/orthographic.rs +++ b/shared/src/cameras/orthographic.rs @@ -114,7 +114,7 @@ impl CameraTrait for OrthographicCamera { Some(CameraRay { ray: camera_ray, - weight: SampledSpectrum::default(), + weight: SampledSpectrum::new(1.), }) } diff --git a/shared/src/cameras/spherical.rs b/shared/src/cameras/spherical.rs index 6caaf11..3400c6c 100644 --- a/shared/src/cameras/spherical.rs +++ b/shared/src/cameras/spherical.rs @@ -58,7 +58,7 @@ impl CameraTrait for SphericalCamera { ); Some(CameraRay { ray: self.render_from_camera(&ray, &mut None), - weight: SampledSpectrum::default(), + weight: SampledSpectrum::new(1.), }) } } diff --git a/shared/src/core/bssrdf.rs b/shared/src/core/bssrdf.rs index 6559eac..bccbed6 100644 --- a/shared/src/core/bssrdf.rs +++ b/shared/src/core/bssrdf.rs @@ -86,7 +86,7 @@ impl From<&SubsurfaceInteraction> for SurfaceInteraction { dvdx: 0., dudy: 0., dvdy: 0., - shape: Ptr::from(&Shape::default()), + shape: Ptr::null(), } } } diff --git a/shared/src/core/medium.rs b/shared/src/core/medium.rs index bc9d18a..f9ab279 100644 --- a/shared/src/core/medium.rs +++ b/shared/src/core/medium.rs @@ -11,7 +11,7 @@ use crate::utils::containers::SampledGrid; use crate::utils::math::{clamp, square}; use crate::utils::rng::Rng; use crate::utils::transform::Transform; -use crate::{gvec_with_capacity, GVec, Ptr}; +use crate::{gvec_with_capacity, leak, GVec, Ptr}; use enum_dispatch::enum_dispatch; use num_traits::Float as NumFloat; @@ -170,7 +170,7 @@ pub struct RayMajorantSegment { } #[repr(C)] -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Debug)] pub enum RayMajorantIterator { Homogeneous(HomogeneousMajorantIterator), DDA(DDAMajorantIterator), @@ -191,7 +191,7 @@ impl Iterator for RayMajorantIterator { } #[repr(C)] -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Debug)] pub struct HomogeneousMajorantIterator { called: bool, seg: RayMajorantSegment, @@ -224,7 +224,7 @@ impl Iterator for HomogeneousMajorantIterator { } #[repr(C)] -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] pub struct DDAMajorantIterator { sigma_t: SampledSpectrum, t_min: Float, @@ -728,20 +728,20 @@ impl Default for MediumInterface { } impl From for MediumInterface { - fn from(medium: Medium) -> Self { + fn from(p: Ptr) -> Self { Self { - inside: Ptr::from(&medium), - outside: Ptr::from(&medium), + inside: p, + outside: p, } } } -impl From<&Medium> for MediumInterface { - fn from(medium: &Medium) -> Self { - Self::from(medium.clone()) - } -} - +// impl From<&Medium> for MediumInterface { +// fn from(medium: &Medium) -> Self { +// Self::from(medium.clone()) +// } +// } +// impl MediumInterface { pub fn new(inside: &Medium, outside: &Medium) -> Self { Self { diff --git a/shared/src/shapes/cylinder.rs b/shared/src/shapes/cylinder.rs index e15f8df..b064123 100644 --- a/shared/src/shapes/cylinder.rs +++ b/shared/src/shapes/cylinder.rs @@ -9,8 +9,8 @@ use crate::core::shape::{ use crate::utils::splines::{ bound_cubic_bezier, cubic_bezier_control_points, evaluate_cubic_bezier, subdivide_cubic_bezier, }; -use crate::utils::transform::{Transform, look_at}; -use crate::{Float, PI, gamma}; +use crate::utils::transform::{look_at, Transform}; +use crate::{gamma, Float, PI}; use crate::core::geometry::{SqrtExt, Tuple}; use crate::utils::interval::Interval; @@ -61,11 +61,10 @@ impl CylinderShape { let di = self .object_from_render .apply_to_vector_interval(&Vector3fi::new_from_vector(r.d)); - // Solve quadratic equation to find cylinder t0 and t1 values>> - let a: Interval = square(di.x()) + square(di.y()) + square(di.z()); - let b: Interval = 2. * (di.x() * oi.x() + di.y() * oi.y() + di.z() * oi.z()); - let c: Interval = - square(oi.x()) + square(oi.y()) + square(oi.z()) - square(Interval::new(self.radius)); + // Solve quadratic equation to find cylinder t0 and t1 values + let a: Interval = square(di.x()) + square(di.y()); + let b: Interval = 2. * (di.x() * oi.x() + di.y() * oi.y()); + let c: Interval = square(oi.x()) + square(oi.y()) - square(Interval::new(self.radius)); let f = b / (2. * a); let vx: Interval = oi.x() - f * di.x(); let vy: Interval = oi.y() - f * di.y(); diff --git a/shared/src/shapes/sphere.rs b/shared/src/shapes/sphere.rs index 21d156e..903620d 100644 --- a/shared/src/shapes/sphere.rs +++ b/shared/src/shapes/sphere.rs @@ -108,7 +108,7 @@ impl SphereShape { mem::swap(&mut t0, &mut t1); } - if t0.high > t_max || t1.low < 0. { + if t0.high >= t_max || t1.low <= 0. { return None; } let mut t_shape_hit = t0;