cargo clippy fixes
This commit is contained in:
parent
e90f9fd6b4
commit
b18987a736
2 changed files with 12 additions and 13 deletions
13
src/main.rs
13
src/main.rs
|
@ -1,4 +1,3 @@
|
||||||
use std::ops::Deref;
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use constants::*;
|
use constants::*;
|
||||||
|
@ -157,10 +156,10 @@ fn main() {
|
||||||
|
|
||||||
let mut allparts = ScadFile::new();
|
let mut allparts = ScadFile::new();
|
||||||
allparts.set_detail(50);
|
allparts.set_detail(50);
|
||||||
for (idx, part) in PARTS.lock().unwrap().to_owned().into_iter().enumerate() {
|
for (idx, part) in PARTS.lock().unwrap().iter().cloned().enumerate() {
|
||||||
allparts.add_object(scad!(Translate2d(vec2(0.0, INF * idx as f32)); part));
|
allparts.add_object(scad!(Translate2d(vec2(0.0, INF * idx as f32)); part));
|
||||||
}
|
}
|
||||||
allparts.write_to_file(format!("build/allparts.scad"));
|
allparts.write_to_file("build/allparts.scad".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SparType {
|
enum SparType {
|
||||||
|
@ -232,7 +231,7 @@ fn topspar_negative(airfoil: &SeligFile, chord: f32, range: Range<f32>) -> ScadO
|
||||||
let mut last: Option<ScadObject> = None;
|
let mut last: Option<ScadObject> = None;
|
||||||
for point in span {
|
for point in span {
|
||||||
let mut current = scad!(Square(vec2(0.001 / chord, CARDBOARD_WIDTH / chord)));
|
let mut current = scad!(Square(vec2(0.001 / chord, CARDBOARD_WIDTH / chord)));
|
||||||
current = scad!(Translate2d(point.clone() - vec2(0.0, CARDBOARD_WIDTH/chord)); current);
|
current = scad!(Translate2d(point - vec2(0.0, CARDBOARD_WIDTH/chord)); current);
|
||||||
if let Some(last_mask) = last {
|
if let Some(last_mask) = last {
|
||||||
let mut hull = scad!(Hull);
|
let mut hull = scad!(Hull);
|
||||||
hull.add_child(current.clone());
|
hull.add_child(current.clone());
|
||||||
|
@ -292,7 +291,7 @@ fn wing(
|
||||||
|
|
||||||
let mut transform = scad!(Translate(vec3(0.0, spacing, 0.0)));
|
let mut transform = scad!(Translate(vec3(0.0, spacing, 0.0)));
|
||||||
|
|
||||||
let strut = strut(&aerofoil, chord, CARDBOARD_WIDTH, &spar);
|
let strut = strut(aerofoil, chord, CARDBOARD_WIDTH, &spar);
|
||||||
transform.add_child(strut);
|
transform.add_child(strut);
|
||||||
wing.add_child(transform);
|
wing.add_child(transform);
|
||||||
}
|
}
|
||||||
|
@ -320,7 +319,7 @@ fn topwing_spar(
|
||||||
|
|
||||||
let spacing = strut_idx as f32 * gap;
|
let spacing = strut_idx as f32 * gap;
|
||||||
|
|
||||||
let shape = topspar_negative(&aerofoil, chord, 0.1..0.6);
|
let shape = topspar_negative(aerofoil, chord, 0.1..0.6);
|
||||||
let extruded = extrude_strut(shape.clone(), scad!(Union), CARDBOARD_WIDTH, chord, false);
|
let extruded = extrude_strut(shape.clone(), scad!(Union), CARDBOARD_WIDTH, chord, false);
|
||||||
|
|
||||||
let mut transform = scad!(Translate(vec3(0.0, spacing, 0.0)));
|
let mut transform = scad!(Translate(vec3(0.0, spacing, 0.0)));
|
||||||
|
@ -360,7 +359,7 @@ fn span_length(points: &[Point]) -> f32 {
|
||||||
if let Some(last) = last_point {
|
if let Some(last) = last_point {
|
||||||
distance += (last - point).magnitude();
|
distance += (last - point).magnitude();
|
||||||
}
|
}
|
||||||
last_point = Some(point.clone());
|
last_point = Some(*point);
|
||||||
}
|
}
|
||||||
distance
|
distance
|
||||||
}
|
}
|
||||||
|
|
12
src/selig.rs
12
src/selig.rs
|
@ -25,7 +25,7 @@ impl SeligFile {
|
||||||
let description = header.next().map(|d| d.to_string());
|
let description = header.next().map(|d| d.to_string());
|
||||||
|
|
||||||
for line in lines {
|
for line in lines {
|
||||||
let mut numbers = line.split(" ").filter(|n| !n.trim().is_empty());
|
let mut numbers = line.split(' ').filter(|n| !n.trim().is_empty());
|
||||||
let x = numbers.next().unwrap().parse().unwrap();
|
let x = numbers.next().unwrap().parse().unwrap();
|
||||||
let y = numbers.next().unwrap().parse().unwrap();
|
let y = numbers.next().unwrap().parse().unwrap();
|
||||||
points.push(Point::new(x, y))
|
points.push(Point::new(x, y))
|
||||||
|
@ -67,7 +67,7 @@ impl Span for Airfoil {
|
||||||
if let Some(last) = last_point {
|
if let Some(last) = last_point {
|
||||||
distance += (last - point).magnitude();
|
distance += (last - point).magnitude();
|
||||||
}
|
}
|
||||||
last_point = Some(point.clone());
|
last_point = Some(*point);
|
||||||
}
|
}
|
||||||
distance
|
distance
|
||||||
}
|
}
|
||||||
|
@ -85,25 +85,25 @@ impl Span for Airfoil {
|
||||||
) {
|
) {
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
// fully within span
|
// fully within span
|
||||||
points.push(point.clone());
|
points.push(*point);
|
||||||
}
|
}
|
||||||
(false, true) => {
|
(false, true) => {
|
||||||
// entering span
|
// entering span
|
||||||
let undershoot = distance - range.start;
|
let undershoot = distance - range.start;
|
||||||
let part_out = (span - undershoot) / span;
|
let part_out = (span - undershoot) / span;
|
||||||
points.push(last.lerp(&point, part_out));
|
points.push(last.lerp(point, part_out));
|
||||||
}
|
}
|
||||||
(true, false) => {
|
(true, false) => {
|
||||||
// exiting span
|
// exiting span
|
||||||
let overshoot = range.end - distance;
|
let overshoot = range.end - distance;
|
||||||
let part_in = (span - overshoot) / span;
|
let part_in = (span - overshoot) / span;
|
||||||
points.push(last.lerp(&point, part_in));
|
points.push(last.lerp(point, part_in));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
distance += span;
|
distance += span;
|
||||||
}
|
}
|
||||||
last_point = Some(point.clone());
|
last_point = Some(*point);
|
||||||
}
|
}
|
||||||
points
|
points
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue