Silencing a bunch of compiler warnings.

This commit is contained in:
Nathan Vegdahl 2016-06-29 15:23:07 -07:00
parent f1df7a3b1a
commit f927dd0d46
10 changed files with 30 additions and 81 deletions

View File

@ -3,7 +3,7 @@
use lerp::lerp_slice;
use bbox::BBox;
use boundable::Boundable;
use ray::{Ray, AccelRay};
use ray::AccelRay;
use algorithm::partition;
#[derive(Debug)]

View File

@ -1,8 +1,7 @@
#![allow(dead_code)]
use std::f32::consts::FRAC_PI_4;
use math::{Vector, Point, Matrix4x4};
use sampling::square_to_circle;
use ray::Ray;
use lerp::lerp_slice;
@ -79,34 +78,3 @@ impl Camera {
Ray::new(orig * transform, dir * transform, time, false)
}
}
/// Maps the unit square to the unit circle.
/// NOTE: x and y should be distributed within [-1, 1],
/// not [0, 1].
fn square_to_circle(x: f32, y: f32) -> (f32, f32) {
debug_assert!(x >= -1.0 && x <= 1.0);
debug_assert!(y >= -1.0 && y <= 1.0);
if x == 0.0 && y == 0.0 {
return (0.0, 0.0);
}
let (radius, angle) = {
if x > y.abs() {
// Quadrant 1
(x, (y / x) * FRAC_PI_4)
} else if y > x.abs() {
// Quadrant 2
(y, (2.0 - (x / y)) * FRAC_PI_4)
} else if x < -(y.abs()) {
// Quadrant 3
(-x, (4.0 + (y / x)) * FRAC_PI_4)
} else {
// Quadrant 4
(-y, (6.0 - (x / y)) * FRAC_PI_4)
}
};
return (radius * angle.cos(), radius * angle.sin());
}

View File

@ -31,7 +31,7 @@ pub trait Color {
}
fn nth_wavelength(hero_wavelength: f32, n: usize) -> f32 {
let mut wl = hero_wavelength + (WL_RANGE_Q * n as f32);
let wl = hero_wavelength + (WL_RANGE_Q * n as f32);
if wl > WL_MAX {
wl - WL_RANGE
} else {
@ -55,23 +55,9 @@ impl SpectralSample {
}
}
pub fn add_color<T: Color>(&mut self, color: &T) {
self.e[0] += color.sample_spectrum(self.wl_n(0));
self.e[1] += color.sample_spectrum(self.wl_n(1));
self.e[2] += color.sample_spectrum(self.wl_n(2));
self.e[3] += color.sample_spectrum(self.wl_n(3));
}
pub fn mul_color<T: Color>(&mut self, color: &T) {
self.e[0] *= color.sample_spectrum(self.wl_n(0));
self.e[1] *= color.sample_spectrum(self.wl_n(1));
self.e[2] *= color.sample_spectrum(self.wl_n(2));
self.e[3] *= color.sample_spectrum(self.wl_n(3));
}
/// Returns the nth wavelength
fn wl_n(&self, n: usize) -> f32 {
let mut wl = self.hero_wavelength + (WL_RANGE_Q * n as f32);
let wl = self.hero_wavelength + (WL_RANGE_Q * n as f32);
if wl > WL_MAX {
wl - WL_RANGE
} else {

View File

@ -1,12 +1,10 @@
use math::{Vector, Point, Matrix4x4, cross};
use math::{Vector, Point, Matrix4x4};
use bbox::BBox;
use boundable::Boundable;
use color::{XYZ, SpectralSample, Color};
use super::LightSource;
use lerp::lerp_slice;
use sampling::{spherical_triangle_solid_angle, uniform_sample_spherical_triangle};
use std::f64::consts::PI as PI_64;
use std::f32::consts::PI as PI_32;
#[derive(Debug)]
pub struct RectangleLight {
@ -105,6 +103,9 @@ impl LightSource for RectangleLight {
wavelength: f32,
time: f32)
-> f32 {
// We're not using these, silence warnings
let _ = (sample_dir, sample_u, sample_v, wavelength);
let dim = lerp_slice(&self.dimensions, time);
// Get the four corners of the rectangle, transformed into world space
@ -136,6 +137,9 @@ impl LightSource for RectangleLight {
wavelength: f32,
time: f32)
-> SpectralSample {
// We're not using these, silence warnings
let _ = (space, dir, u, v);
let dim = lerp_slice(&self.dimensions, time);
let col = lerp_slice(&self.colors, time);

View File

@ -6,7 +6,6 @@ use super::LightSource;
use lerp::lerp_slice;
use sampling::{uniform_sample_cone, uniform_sample_cone_pdf, uniform_sample_sphere};
use std::f64::consts::PI as PI_64;
use std::f32::consts::PI as PI_32;
#[derive(Debug)]
pub struct SphereLight {
@ -52,8 +51,7 @@ impl LightSource for SphereLight {
// Create a coordinate system from the vector between the
// point and the center of the light
let (x, y, z): (Vector, Vector, Vector);
z = pos - arr;
let z = pos - arr;
let d2: f64 = z.length2() as f64; // Distance from center of sphere squared
let d = d2.sqrt(); // Distance from center of sphere
let (z, x, y) = coordinate_system_from_vector(z);
@ -79,11 +77,11 @@ impl LightSource for SphereLight {
// Convert to a point on the sphere.
// The technique for this is from "Akalin" on ompf2.com:
// http://ompf2.com/viewtopic.php?f=3&t=1914#p4414
let D = 1.0 - (d2 * sin_theta * sin_theta / (radius * radius));
let cos_a = if D <= 0.0 {
let dd = 1.0 - (d2 * sin_theta * sin_theta / (radius * radius));
let cos_a = if dd <= 0.0 {
sin_theta_max
} else {
((d / radius) * sin_theta2) + (cos_theta * D.sqrt())
((d / radius) * sin_theta2) + (cos_theta * dd.sqrt())
};
let sin_a = ((1.0 - (cos_a * cos_a)).max(0.0)).sqrt();
let phi = v as f64 * 2.0 * PI_64;
@ -114,6 +112,9 @@ impl LightSource for SphereLight {
wavelength: f32,
time: f32)
-> f32 {
// We're not using these, silence warnings
let _ = (sample_dir, sample_u, sample_v, wavelength);
// TODO: use transform space correctly
let pos = Point::new(0.0, 0.0, 0.0) * space.inverse();
let radius: f64 = lerp_slice(&self.radii, time) as f64;
@ -141,6 +142,9 @@ impl LightSource for SphereLight {
wavelength: f32,
time: f32)
-> SpectralSample {
// We're not using these, silence warnings
let _ = (space, dir, u, v);
// TODO: use transform space correctly
let radius = lerp_slice(&self.radii, time) as f64;
let col = lerp_slice(&self.colors, time);

View File

@ -5,11 +5,10 @@ use std::result::Result;
use nom::IResult;
use super::DataTree;
use super::basics::{ws_usize, ws_f32};
use super::basics::ws_f32;
use super::psy::PsyParseError;
use light::{SphereLight, RectangleLight};
use math::Point;
use color::XYZ;
pub fn parse_sphere_light(tree: &DataTree) -> Result<SphereLight, PsyParseError> {

View File

@ -14,11 +14,11 @@ use ray::Ray;
use assembly::Object;
use tracer::Tracer;
use halton;
use math::{Vector, Matrix4x4, dot, fast_logit};
use math::{Matrix4x4, dot, fast_logit};
use image::Image;
use surface;
use scene::Scene;
use color::{Color, XYZ, rec709e_to_xyz, map_0_1_to_wavelength};
use color::{Color, XYZ, map_0_1_to_wavelength};
#[derive(Debug)]
pub struct Renderer {
@ -231,10 +231,10 @@ impl LightPath {
0 => {
self.round += 1;
if let &surface::SurfaceIntersection::Hit { t: _,
pos: pos,
nor: nor,
pos,
nor,
local_space: _,
uv } = isect {
uv: _ } = isect {
// Hit something! Do lighting!
if scene.root.light_accel.len() > 0 {
// Get the light and the mapping to its local space

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
use math::{Vector, dot};
use std::f64::consts::PI as PI_64;
@ -5,7 +7,6 @@ use std::f32::consts::PI as PI_32;
use std::f32::consts::FRAC_PI_4 as QPI_32;
/// Maps the unit square to the unit circle.
/// Modifies x and y in place.
/// NOTE: x and y should be distributed within [-1, 1],
/// not [0, 1].
pub fn square_to_circle(x: f32, y: f32) -> (f32, f32) {

View File

@ -1,7 +1,7 @@
#![allow(dead_code)]
use lerp::{lerp, lerp_slice, lerp_slice_with};
use math::{Point, Normal, Matrix4x4, cross};
use math::{Point, Matrix4x4, cross};
use ray::{Ray, AccelRay};
use triangle;
use bbox::BBox;

View File

@ -144,19 +144,6 @@ impl TransformStack {
ts
}
fn with_capacity(capacity: usize) -> TransformStack {
let mut ts = TransformStack {
stack: Vec::with_capacity(capacity),
stack_indices: Vec::with_capacity(capacity),
scratch_space: Vec::with_capacity(capacity),
};
ts.stack_indices.push(0);
ts.stack_indices.push(0);
ts
}
fn push(&mut self, xforms: &[Matrix4x4]) {
assert!(xforms.len() > 0);