Use par_iter where it counts
This commit is contained in:
parent
a47dd96fa1
commit
4694921b46
1 changed files with 3 additions and 9 deletions
12
src/main.rs
12
src/main.rs
|
@ -92,7 +92,7 @@ fn duplicate(
|
||||||
height_scalar: f32,
|
height_scalar: f32,
|
||||||
) -> Vec<Vector3<f32>> {
|
) -> Vec<Vector3<f32>> {
|
||||||
positions
|
positions
|
||||||
.par_iter()
|
.iter()
|
||||||
.map(|point| {
|
.map(|point| {
|
||||||
Vector3::new(
|
Vector3::new(
|
||||||
point.x + translation.x,
|
point.x + translation.x,
|
||||||
|
@ -182,7 +182,7 @@ fn copy_faces(
|
||||||
let offset = n_positions * current_value + 1;
|
let offset = n_positions * current_value + 1;
|
||||||
|
|
||||||
faces
|
faces
|
||||||
.par_iter()
|
.iter()
|
||||||
.map(|current_face| {
|
.map(|current_face| {
|
||||||
current_face
|
current_face
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -225,19 +225,15 @@ fn save(filename: &Path, positions: Vec<Vector3<f32>>, faces: Vec<Vec<IndexTuple
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
let path = Path::new("data/test.obj");
|
let path = Path::new("data/teapot.obj");
|
||||||
let maybe_obj: Result<Obj<SimplePolygon>> = Obj::load(&path);
|
let maybe_obj: Result<Obj<SimplePolygon>> = Obj::load(&path);
|
||||||
|
|
||||||
if let Ok(obj) = maybe_obj {
|
if let Ok(obj) = maybe_obj {
|
||||||
println!("Position: {:?}", obj.position);
|
|
||||||
|
|
||||||
let layers = 10;
|
let layers = 10;
|
||||||
let spacing = 1.0;
|
let spacing = 1.0;
|
||||||
|
|
||||||
let (length, width) = find_l_w(&obj);
|
let (length, width) = find_l_w(&obj);
|
||||||
|
|
||||||
println!("Length: {} Width: {}", length, width);
|
|
||||||
|
|
||||||
let input_positions: Vec<_> = obj.position
|
let input_positions: Vec<_> = obj.position
|
||||||
.iter()
|
.iter()
|
||||||
.map(|point| Vector3::new(point[0], point[1], point[2]))
|
.map(|point| Vector3::new(point[0], point[1], point[2]))
|
||||||
|
@ -245,8 +241,6 @@ fn main() {
|
||||||
|
|
||||||
let output_positions = generate_city(&input_positions, layers, spacing, length, width);
|
let output_positions = generate_city(&input_positions, layers, spacing, length, width);
|
||||||
|
|
||||||
println!("Objects: {:?}", obj.objects[0].groups[0].polys[0]);
|
|
||||||
|
|
||||||
let output_faces = copy_faces(
|
let output_faces = copy_faces(
|
||||||
&obj.objects[0].groups[0].polys,
|
&obj.objects[0].groups[0].polys,
|
||||||
obj.position.len(),
|
obj.position.len(),
|
||||||
|
|
Reference in a new issue