Continguing fixes. Some issues with memory leaks
This commit is contained in:
parent
79c87a6c15
commit
63c10c6573
7 changed files with 24 additions and 25 deletions
|
|
@ -41,7 +41,7 @@ impl BxDFTrait for DiffuseBxDF {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut wi = sample_cosine_hemisphere(u);
|
let mut wi = sample_cosine_hemisphere(u);
|
||||||
if wo.z() == 0. {
|
if wo.z() < 0. {
|
||||||
wi[2] *= -1.;
|
wi[2] *= -1.;
|
||||||
}
|
}
|
||||||
let pdf = cosine_hemisphere_pdf(abs_cos_theta(wi));
|
let pdf = cosine_hemisphere_pdf(abs_cos_theta(wi));
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ impl CameraTrait for OrthographicCamera {
|
||||||
|
|
||||||
Some(CameraRay {
|
Some(CameraRay {
|
||||||
ray: camera_ray,
|
ray: camera_ray,
|
||||||
weight: SampledSpectrum::default(),
|
weight: SampledSpectrum::new(1.),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ impl CameraTrait for SphericalCamera {
|
||||||
);
|
);
|
||||||
Some(CameraRay {
|
Some(CameraRay {
|
||||||
ray: self.render_from_camera(&ray, &mut None),
|
ray: self.render_from_camera(&ray, &mut None),
|
||||||
weight: SampledSpectrum::default(),
|
weight: SampledSpectrum::new(1.),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ impl From<&SubsurfaceInteraction> for SurfaceInteraction {
|
||||||
dvdx: 0.,
|
dvdx: 0.,
|
||||||
dudy: 0.,
|
dudy: 0.,
|
||||||
dvdy: 0.,
|
dvdy: 0.,
|
||||||
shape: Ptr::from(&Shape::default()),
|
shape: Ptr::null(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::utils::containers::SampledGrid;
|
||||||
use crate::utils::math::{clamp, square};
|
use crate::utils::math::{clamp, square};
|
||||||
use crate::utils::rng::Rng;
|
use crate::utils::rng::Rng;
|
||||||
use crate::utils::transform::Transform;
|
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 enum_dispatch::enum_dispatch;
|
||||||
use num_traits::Float as NumFloat;
|
use num_traits::Float as NumFloat;
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ pub struct RayMajorantSegment {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum RayMajorantIterator {
|
pub enum RayMajorantIterator {
|
||||||
Homogeneous(HomogeneousMajorantIterator),
|
Homogeneous(HomogeneousMajorantIterator),
|
||||||
DDA(DDAMajorantIterator),
|
DDA(DDAMajorantIterator),
|
||||||
|
|
@ -191,7 +191,7 @@ impl Iterator for RayMajorantIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct HomogeneousMajorantIterator {
|
pub struct HomogeneousMajorantIterator {
|
||||||
called: bool,
|
called: bool,
|
||||||
seg: RayMajorantSegment,
|
seg: RayMajorantSegment,
|
||||||
|
|
@ -224,7 +224,7 @@ impl Iterator for HomogeneousMajorantIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DDAMajorantIterator {
|
pub struct DDAMajorantIterator {
|
||||||
sigma_t: SampledSpectrum,
|
sigma_t: SampledSpectrum,
|
||||||
t_min: Float,
|
t_min: Float,
|
||||||
|
|
@ -728,20 +728,20 @@ impl Default for MediumInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Medium> for MediumInterface {
|
impl From<Medium> for MediumInterface {
|
||||||
fn from(medium: Medium) -> Self {
|
fn from(p: Ptr<Medium>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inside: Ptr::from(&medium),
|
inside: p,
|
||||||
outside: Ptr::from(&medium),
|
outside: p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Medium> for MediumInterface {
|
// impl From<&Medium> for MediumInterface {
|
||||||
fn from(medium: &Medium) -> Self {
|
// fn from(medium: &Medium) -> Self {
|
||||||
Self::from(medium.clone())
|
// Self::from(medium.clone())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
impl MediumInterface {
|
impl MediumInterface {
|
||||||
pub fn new(inside: &Medium, outside: &Medium) -> Self {
|
pub fn new(inside: &Medium, outside: &Medium) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ use crate::core::shape::{
|
||||||
use crate::utils::splines::{
|
use crate::utils::splines::{
|
||||||
bound_cubic_bezier, cubic_bezier_control_points, evaluate_cubic_bezier, subdivide_cubic_bezier,
|
bound_cubic_bezier, cubic_bezier_control_points, evaluate_cubic_bezier, subdivide_cubic_bezier,
|
||||||
};
|
};
|
||||||
use crate::utils::transform::{Transform, look_at};
|
use crate::utils::transform::{look_at, Transform};
|
||||||
use crate::{Float, PI, gamma};
|
use crate::{gamma, Float, PI};
|
||||||
|
|
||||||
use crate::core::geometry::{SqrtExt, Tuple};
|
use crate::core::geometry::{SqrtExt, Tuple};
|
||||||
use crate::utils::interval::Interval;
|
use crate::utils::interval::Interval;
|
||||||
|
|
@ -61,11 +61,10 @@ impl CylinderShape {
|
||||||
let di = self
|
let di = self
|
||||||
.object_from_render
|
.object_from_render
|
||||||
.apply_to_vector_interval(&Vector3fi::new_from_vector(r.d));
|
.apply_to_vector_interval(&Vector3fi::new_from_vector(r.d));
|
||||||
// Solve quadratic equation to find cylinder t0 and t1 values>>
|
// Solve quadratic equation to find cylinder t0 and t1 values
|
||||||
let a: Interval = square(di.x()) + square(di.y()) + square(di.z());
|
let a: Interval = square(di.x()) + square(di.y());
|
||||||
let b: Interval = 2. * (di.x() * oi.x() + di.y() * oi.y() + di.z() * oi.z());
|
let b: Interval = 2. * (di.x() * oi.x() + di.y() * oi.y());
|
||||||
let c: Interval =
|
let c: Interval = square(oi.x()) + square(oi.y()) - square(Interval::new(self.radius));
|
||||||
square(oi.x()) + square(oi.y()) + square(oi.z()) - square(Interval::new(self.radius));
|
|
||||||
let f = b / (2. * a);
|
let f = b / (2. * a);
|
||||||
let vx: Interval = oi.x() - f * di.x();
|
let vx: Interval = oi.x() - f * di.x();
|
||||||
let vy: Interval = oi.y() - f * di.y();
|
let vy: Interval = oi.y() - f * di.y();
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ impl SphereShape {
|
||||||
mem::swap(&mut t0, &mut t1);
|
mem::swap(&mut t0, &mut t1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if t0.high > t_max || t1.low < 0. {
|
if t0.high >= t_max || t1.low <= 0. {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut t_shape_hit = t0;
|
let mut t_shape_hit = t0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue