Fix deprecation warnings from rustc.
This commit is contained in:
parent
6e555456ba
commit
e23fe4bb36
|
@ -128,5 +128,4 @@ mod tests {
|
||||||
assert_eq!(increment_ulp(decrement_ulp(1.2)), 1.2);
|
assert_eq!(increment_ulp(decrement_ulp(1.2)), 1.2);
|
||||||
assert_eq!(increment_ulp(decrement_ulp(-1.2)), -1.2);
|
assert_eq!(increment_ulp(decrement_ulp(-1.2)), -1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
10
src/image.rs
10
src/image.rs
|
@ -100,15 +100,15 @@ impl Image {
|
||||||
let mut f = io::BufWriter::new(File::create(path)?);
|
let mut f = io::BufWriter::new(File::create(path)?);
|
||||||
|
|
||||||
// Write header
|
// Write header
|
||||||
r#try!(write!(f, "P3\n{} {}\n255\n", self.res.0, self.res.1));
|
write!(f, "P3\n{} {}\n255\n", self.res.0, self.res.1)?;
|
||||||
|
|
||||||
// Write pixels
|
// Write pixels
|
||||||
for y in 0..self.res.1 {
|
for y in 0..self.res.1 {
|
||||||
for x in 0..self.res.0 {
|
for x in 0..self.res.0 {
|
||||||
let (r, g, b) = quantize_tri_255(xyz_to_srgbe(self.get(x, y).to_tuple()));
|
let (r, g, b) = quantize_tri_255(xyz_to_srgbe(self.get(x, y).to_tuple()));
|
||||||
r#try!(write!(f, "{} {} {} ", r, g, b));
|
write!(f, "{} {} {} ", r, g, b)?;
|
||||||
}
|
}
|
||||||
r#try!(write!(f, "\n"));
|
write!(f, "\n")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
|
@ -120,14 +120,14 @@ impl Image {
|
||||||
let mut f = io::BufWriter::new(File::create(path)?);
|
let mut f = io::BufWriter::new(File::create(path)?);
|
||||||
|
|
||||||
// Write header
|
// Write header
|
||||||
r#try!(write!(f, "P6\n{} {}\n255\n", self.res.0, self.res.1));
|
write!(f, "P6\n{} {}\n255\n", self.res.0, self.res.1)?;
|
||||||
|
|
||||||
// Write pixels
|
// Write pixels
|
||||||
for y in 0..self.res.1 {
|
for y in 0..self.res.1 {
|
||||||
for x in 0..self.res.0 {
|
for x in 0..self.res.0 {
|
||||||
let (r, g, b) = quantize_tri_255(xyz_to_srgbe(self.get(x, y).to_tuple()));
|
let (r, g, b) = quantize_tri_255(xyz_to_srgbe(self.get(x, y).to_tuple()));
|
||||||
let d = [r, g, b];
|
let d = [r, g, b];
|
||||||
r#try!(f.write_all(&d));
|
f.write_all(&d)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ impl<'a> Surface for RectangleLight<'a> {
|
||||||
rays: &mut RayBatch,
|
rays: &mut RayBatch,
|
||||||
ray_stack: &mut RayStack,
|
ray_stack: &mut RayStack,
|
||||||
isects: &mut [SurfaceIntersection],
|
isects: &mut [SurfaceIntersection],
|
||||||
shader: &SurfaceShader,
|
shader: &dyn SurfaceShader,
|
||||||
space: &[Matrix4x4],
|
space: &[Matrix4x4],
|
||||||
) {
|
) {
|
||||||
let _ = shader; // Silence 'unused' warning
|
let _ = shader; // Silence 'unused' warning
|
||||||
|
|
|
@ -209,7 +209,7 @@ impl<'a> Surface for SphereLight<'a> {
|
||||||
rays: &mut RayBatch,
|
rays: &mut RayBatch,
|
||||||
ray_stack: &mut RayStack,
|
ray_stack: &mut RayStack,
|
||||||
isects: &mut [SurfaceIntersection],
|
isects: &mut [SurfaceIntersection],
|
||||||
shader: &SurfaceShader,
|
shader: &dyn SurfaceShader,
|
||||||
space: &[Matrix4x4],
|
space: &[Matrix4x4],
|
||||||
) {
|
) {
|
||||||
let _ = shader; // Silence 'unused' warning
|
let _ = shader; // Silence 'unused' warning
|
||||||
|
|
|
@ -455,7 +455,7 @@ fn parse_camera<'a>(arena: &'a MemArena, tree: &'a DataTree) -> Result<Camera<'a
|
||||||
fn parse_world<'a>(arena: &'a MemArena, tree: &'a DataTree) -> Result<World<'a>, PsyParseError> {
|
fn parse_world<'a>(arena: &'a MemArena, tree: &'a DataTree) -> Result<World<'a>, PsyParseError> {
|
||||||
if tree.is_internal() {
|
if tree.is_internal() {
|
||||||
let background_color;
|
let background_color;
|
||||||
let mut lights: Vec<&WorldLightSource> = Vec::new();
|
let mut lights: Vec<&dyn WorldLightSource> = Vec::new();
|
||||||
|
|
||||||
// Parse background shader
|
// Parse background shader
|
||||||
let bgs = {
|
let bgs = {
|
||||||
|
|
|
@ -24,7 +24,7 @@ use super::{
|
||||||
pub fn parse_surface_shader<'a>(
|
pub fn parse_surface_shader<'a>(
|
||||||
arena: &'a MemArena,
|
arena: &'a MemArena,
|
||||||
tree: &'a DataTree,
|
tree: &'a DataTree,
|
||||||
) -> Result<&'a SurfaceShader, PsyParseError> {
|
) -> Result<&'a dyn SurfaceShader, PsyParseError> {
|
||||||
let type_name = if let Some((_, text, _)) = tree.iter_leaf_children_with_type("Type").nth(0) {
|
let type_name = if let Some((_, text, _)) = tree.iter_leaf_children_with_type("Type").nth(0) {
|
||||||
text.trim()
|
text.trim()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub struct Assembly<'a> {
|
||||||
pub xforms: &'a [Matrix4x4],
|
pub xforms: &'a [Matrix4x4],
|
||||||
|
|
||||||
// Surface shader list
|
// Surface shader list
|
||||||
pub surface_shaders: &'a [&'a SurfaceShader],
|
pub surface_shaders: &'a [&'a dyn SurfaceShader],
|
||||||
|
|
||||||
// Object list
|
// Object list
|
||||||
pub objects: &'a [Object<'a>],
|
pub objects: &'a [Object<'a>],
|
||||||
|
@ -155,7 +155,7 @@ pub struct AssemblyBuilder<'a> {
|
||||||
xforms: Vec<Matrix4x4>,
|
xforms: Vec<Matrix4x4>,
|
||||||
|
|
||||||
// Shader list
|
// Shader list
|
||||||
surface_shaders: Vec<&'a SurfaceShader>,
|
surface_shaders: Vec<&'a dyn SurfaceShader>,
|
||||||
surface_shader_map: HashMap<String, usize>, // map Name -> Index
|
surface_shader_map: HashMap<String, usize>, // map Name -> Index
|
||||||
|
|
||||||
// Object list
|
// Object list
|
||||||
|
@ -182,7 +182,7 @@ impl<'a> AssemblyBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_surface_shader(&mut self, name: &str, shader: &'a SurfaceShader) {
|
pub fn add_surface_shader(&mut self, name: &str, shader: &'a dyn SurfaceShader) {
|
||||||
// Make sure the name hasn't already been used.
|
// Make sure the name hasn't already been used.
|
||||||
if self.surface_shader_map.contains_key(name) {
|
if self.surface_shader_map.contains_key(name) {
|
||||||
panic!("Attempted to add surface shader to assembly with a name that already exists.");
|
panic!("Attempted to add surface shader to assembly with a name that already exists.");
|
||||||
|
@ -397,8 +397,8 @@ impl<'a> AssemblyBuilder<'a> {
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum Object<'a> {
|
pub enum Object<'a> {
|
||||||
Surface(&'a Surface),
|
Surface(&'a dyn Surface),
|
||||||
SurfaceLight(&'a SurfaceLight),
|
SurfaceLight(&'a dyn SurfaceLight),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
|
|
@ -3,5 +3,5 @@ use crate::{color::Color, light::WorldLightSource};
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct World<'a> {
|
pub struct World<'a> {
|
||||||
pub background_color: Color,
|
pub background_color: Color,
|
||||||
pub lights: &'a [&'a WorldLightSource],
|
pub lights: &'a [&'a dyn WorldLightSource],
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub trait Surface: Boundable + Debug + Sync {
|
||||||
rays: &mut RayBatch,
|
rays: &mut RayBatch,
|
||||||
ray_stack: &mut RayStack,
|
ray_stack: &mut RayStack,
|
||||||
isects: &mut [SurfaceIntersection],
|
isects: &mut [SurfaceIntersection],
|
||||||
shader: &SurfaceShader,
|
shader: &dyn SurfaceShader,
|
||||||
space: &[Matrix4x4],
|
space: &[Matrix4x4],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl<'a> Surface for TriangleMesh<'a> {
|
||||||
rays: &mut RayBatch,
|
rays: &mut RayBatch,
|
||||||
ray_stack: &mut RayStack,
|
ray_stack: &mut RayStack,
|
||||||
isects: &mut [SurfaceIntersection],
|
isects: &mut [SurfaceIntersection],
|
||||||
shader: &SurfaceShader,
|
shader: &dyn SurfaceShader,
|
||||||
space: &[Matrix4x4],
|
space: &[Matrix4x4],
|
||||||
) {
|
) {
|
||||||
// Precalculate transform for non-motion blur cases
|
// Precalculate transform for non-motion blur cases
|
||||||
|
|
|
@ -152,7 +152,7 @@ impl<'a> TracerInner<'a> {
|
||||||
fn trace_object<'b>(
|
fn trace_object<'b>(
|
||||||
&'b mut self,
|
&'b mut self,
|
||||||
obj: &Object,
|
obj: &Object,
|
||||||
surface_shader: Option<&SurfaceShader>,
|
surface_shader: Option<&dyn SurfaceShader>,
|
||||||
rays: &mut RayBatch,
|
rays: &mut RayBatch,
|
||||||
ray_stack: &mut RayStack,
|
ray_stack: &mut RayStack,
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user