Clippy fixes

This commit is contained in:
2026-01-16 16:32:31 +11:00
parent 31fd34d083
commit dc8d406715
4 changed files with 13 additions and 16 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ fn main() {
let now = Instant::now(); let now = Instant::now();
render( &scene, &mut *sbuffer); render( &scene, &mut sbuffer);
set_scene(dt, &mut scene); set_scene(dt, &mut scene);
let elapsed = now.elapsed(); // Timing operations let elapsed = now.elapsed(); // Timing operations
+8 -9
View File
@@ -1,4 +1,3 @@
use std::collections::HashMap;
use crate::consts::*; use crate::consts::*;
@@ -53,17 +52,17 @@ impl Object {
}; };
for (i_start, i_end) in ret.edge_indices.iter() { for (i_start, i_end) in ret.edge_indices.iter() {
ret.edges.push((ret.vertices[*i_start].clone(), ret.vertices[*i_end].clone())); ret.edges.push((ret.vertices[*i_start], ret.vertices[*i_end]));
} }
for (i_one, i_two, i_three /* The three vertices of the triangle */) in ret.triangle_indices.iter() { for (i_one, i_two, i_three /* The three vertices of the triangle */) in ret.triangle_indices.iter() {
ret.triangles.push((ret.vertices[*i_one].clone(), ret.vertices[*i_two].clone(), ret.vertices[*i_three].clone())); ret.triangles.push((ret.vertices[*i_one], ret.vertices[*i_two], ret.vertices[*i_three]));
} }
ret ret
} }
fn ear_clip(polygon: &Vec<Point3D>) -> Vec<(Point3D, Point3D, Point3D)> { fn ear_clip(_polygon: &Vec<Point3D>) -> Vec<(Point3D, Point3D, Point3D)> {
todo!() todo!()
} }
@@ -74,7 +73,7 @@ impl Object {
// OPTIMISATION: Do we need to re-initalise self.{edges, faces, triangles} every execution? // OPTIMISATION: Do we need to re-initalise self.{edges, faces, triangles} every execution?
self.edges = vec![]; self.edges = vec![];
for (i_start, i_end) in self.edge_indices.iter() { for (i_start, i_end) in self.edge_indices.iter() {
self.edges.push((self.vertices[*i_start].clone(), self.vertices[*i_end].clone())); self.edges.push((self.vertices[*i_start], self.vertices[*i_end]));
} }
self.faces = vec![]; self.faces = vec![];
@@ -84,10 +83,10 @@ impl Object {
self.triangles = vec![]; self.triangles = vec![];
for face in self.faces.iter() { for face in self.faces.iter() {
self.triangles.append(&mut Self::ear_clip(&face)); self.triangles.append(&mut Self::ear_clip(face));
} }
for (i_one, i_two, i_three /* The three vertices of the triangle */) in self.triangle_indices.iter() { for (i_one, i_two, i_three /* The three vertices of the triangle */) in self.triangle_indices.iter() {
self.triangles.push((self.vertices[*i_one].clone(), self.vertices[*i_two].clone(), self.vertices[*i_three].clone())); self.triangles.push((self.vertices[*i_one], self.vertices[*i_two], self.vertices[*i_three]));
} }
} }
} }
@@ -147,8 +146,8 @@ impl Point2D {
// Pythagorean formula // Pythagorean formula
// TODO: use hypot function // TODO: use hypot function
f64::sqrt( f64::sqrt(
(f64::powf(p2.x.max(p1.x) - p1.x.min(p2.x), 2.0) f64::powf(p2.x.max(p1.x) - p1.x.min(p2.x), 2.0)
+ f64::powf(p2.y.max(p1.y) - p1.y.min(p2.y), 2.0)) as f64, + f64::powf(p2.y.max(p1.y) - p1.y.min(p2.y), 2.0),
) )
} }
+2 -2
View File
@@ -1,5 +1,5 @@
use crate::consts::*; use crate::consts::*;
use crate::points::{Point2D, Point3D}; use crate::points::Point2D;
use crate::Scene; use crate::Scene;
type Pixel = u32; type Pixel = u32;
@@ -53,7 +53,7 @@ pub fn render(scene: &Scene, buf: &mut [u32]) {
} }
let m = (end.y - start.y) / (end.x - start.x); // m = rise/run let m = (end.y - start.y) / (end.x - start.x); // m = rise/run
let c = start.y as f64 - m * start.x as f64; // c = y - mx let c = start.y - m * start.x; // c = y - mx
for x in (start.x.min(end.x) as usize)..=(end.x.max(start.x) as usize) { for x in (start.x.min(end.x) as usize)..=(end.x.max(start.x) as usize) {
let x = x as f64; let x = x as f64;
+2 -4
View File
@@ -1,11 +1,9 @@
use core::f64;
use std::time::Duration; use std::time::Duration;
use crate::points::Point3D;
use crate::points::Scene; use crate::points::Scene;
pub fn set_scene(dt: Duration, scene: &mut Scene) { pub fn set_scene(_dt: Duration, scene: &mut Scene) {
for obj in scene { for obj in scene {
for vertex in obj.vertices.iter_mut() { for _vertex in obj.vertices.iter_mut() {
// vertex.z += 1.0; // vertex.z += 1.0;
} }