library: render: mesh: from_slice to build Vector
This commit is contained in:
parent
f0d36c7d7b
commit
cca40bcb8e
|
@ -1,7 +1,7 @@
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use nalgebra::{Similarity3, Unit};
|
use nalgebra::{Similarity3, Unit, VectorSlice3};
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
@ -69,27 +69,18 @@ impl TryFrom<Wavefront> for Mesh {
|
||||||
// We apply the (arguably useless) scaling to the vectors in case it is
|
// We apply the (arguably useless) scaling to the vectors in case it is
|
||||||
// negative, which would invert their direction
|
// negative, which would invert their direction
|
||||||
let norm_a = {
|
let norm_a = {
|
||||||
let vec = Vector::new(
|
let vec: Vector =
|
||||||
mesh.normals[a * 3],
|
VectorSlice3::from_slice(&mesh.normals[(a * 3)..(a * 3 + 3)]).into();
|
||||||
mesh.normals[a * 3 + 1],
|
|
||||||
mesh.normals[a * 3 + 2],
|
|
||||||
);
|
|
||||||
Unit::new_normalize(transform * vec)
|
Unit::new_normalize(transform * vec)
|
||||||
};
|
};
|
||||||
let norm_b = {
|
let norm_b = {
|
||||||
let vec = Vector::new(
|
let vec: Vector =
|
||||||
mesh.normals[b * 3],
|
VectorSlice3::from_slice(&mesh.normals[(b * 3)..(b * 3 + 3)]).into();
|
||||||
mesh.normals[b * 3 + 1],
|
|
||||||
mesh.normals[b * 3 + 2],
|
|
||||||
);
|
|
||||||
Unit::new_normalize(transform * vec)
|
Unit::new_normalize(transform * vec)
|
||||||
};
|
};
|
||||||
let norm_c = {
|
let norm_c = {
|
||||||
let vec = Vector::new(
|
let vec: Vector =
|
||||||
mesh.normals[c * 3],
|
VectorSlice3::from_slice(&mesh.normals[(c * 3)..(c * 3 + 3)]).into();
|
||||||
mesh.normals[c * 3 + 1],
|
|
||||||
mesh.normals[c * 3 + 2],
|
|
||||||
);
|
|
||||||
Unit::new_normalize(transform * vec)
|
Unit::new_normalize(transform * vec)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue