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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
10
src/image.rs
10
src/image.rs
|
@ -100,15 +100,15 @@ impl Image {
|
|||
let mut f = io::BufWriter::new(File::create(path)?);
|
||||
|
||||
// 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
|
||||
for y in 0..self.res.1 {
|
||||
for x in 0..self.res.0 {
|
||||
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
|
||||
|
@ -120,14 +120,14 @@ impl Image {
|
|||
let mut f = io::BufWriter::new(File::create(path)?);
|
||||
|
||||
// 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
|
||||
for y in 0..self.res.1 {
|
||||
for x in 0..self.res.0 {
|
||||
let (r, g, b) = quantize_tri_255(xyz_to_srgbe(self.get(x, y).to_tuple()));
|
||||
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,
|
||||
ray_stack: &mut RayStack,
|
||||
isects: &mut [SurfaceIntersection],
|
||||
shader: &SurfaceShader,
|
||||
shader: &dyn SurfaceShader,
|
||||
space: &[Matrix4x4],
|
||||
) {
|
||||
let _ = shader; // Silence 'unused' warning
|
||||
|
|
|
@ -209,7 +209,7 @@ impl<'a> Surface for SphereLight<'a> {
|
|||
rays: &mut RayBatch,
|
||||
ray_stack: &mut RayStack,
|
||||
isects: &mut [SurfaceIntersection],
|
||||
shader: &SurfaceShader,
|
||||
shader: &dyn SurfaceShader,
|
||||
space: &[Matrix4x4],
|
||||
) {
|
||||
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> {
|
||||
if tree.is_internal() {
|
||||
let background_color;
|
||||
let mut lights: Vec<&WorldLightSource> = Vec::new();
|
||||
let mut lights: Vec<&dyn WorldLightSource> = Vec::new();
|
||||
|
||||
// Parse background shader
|
||||
let bgs = {
|
||||
|
|
|
@ -24,7 +24,7 @@ use super::{
|
|||
pub fn parse_surface_shader<'a>(
|
||||
arena: &'a MemArena,
|
||||
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) {
|
||||
text.trim()
|
||||
} else {
|
||||
|
|
|
@ -24,7 +24,7 @@ pub struct Assembly<'a> {
|
|||
pub xforms: &'a [Matrix4x4],
|
||||
|
||||
// Surface shader list
|
||||
pub surface_shaders: &'a [&'a SurfaceShader],
|
||||
pub surface_shaders: &'a [&'a dyn SurfaceShader],
|
||||
|
||||
// Object list
|
||||
pub objects: &'a [Object<'a>],
|
||||
|
@ -155,7 +155,7 @@ pub struct AssemblyBuilder<'a> {
|
|||
xforms: Vec<Matrix4x4>,
|
||||
|
||||
// Shader list
|
||||
surface_shaders: Vec<&'a SurfaceShader>,
|
||||
surface_shaders: Vec<&'a dyn SurfaceShader>,
|
||||
surface_shader_map: HashMap<String, usize>, // map Name -> Index
|
||||
|
||||
// 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.
|
||||
if self.surface_shader_map.contains_key(name) {
|
||||
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)]
|
||||
pub enum Object<'a> {
|
||||
Surface(&'a Surface),
|
||||
SurfaceLight(&'a SurfaceLight),
|
||||
Surface(&'a dyn Surface),
|
||||
SurfaceLight(&'a dyn SurfaceLight),
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
|
|
@ -3,5 +3,5 @@ use crate::{color::Color, light::WorldLightSource};
|
|||
#[derive(Debug)]
|
||||
pub struct World<'a> {
|
||||
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,
|
||||
ray_stack: &mut RayStack,
|
||||
isects: &mut [SurfaceIntersection],
|
||||
shader: &SurfaceShader,
|
||||
shader: &dyn SurfaceShader,
|
||||
space: &[Matrix4x4],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ impl<'a> Surface for TriangleMesh<'a> {
|
|||
rays: &mut RayBatch,
|
||||
ray_stack: &mut RayStack,
|
||||
isects: &mut [SurfaceIntersection],
|
||||
shader: &SurfaceShader,
|
||||
shader: &dyn SurfaceShader,
|
||||
space: &[Matrix4x4],
|
||||
) {
|
||||
// Precalculate transform for non-motion blur cases
|
||||
|
|
|
@ -152,7 +152,7 @@ impl<'a> TracerInner<'a> {
|
|||
fn trace_object<'b>(
|
||||
&'b mut self,
|
||||
obj: &Object,
|
||||
surface_shader: Option<&SurfaceShader>,
|
||||
surface_shader: Option<&dyn SurfaceShader>,
|
||||
rays: &mut RayBatch,
|
||||
ray_stack: &mut RayStack,
|
||||
) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user