use super::super::pre::*; impl Cast> for mat3 { fn to(((v11, v12, v13, _), (v21, v22, v23, _), (v31, v32, v33, _), _): mat4) -> Self { ((v11, v12, v13), (v21, v22, v23), (v31, v32, v33)) } } impl Cast> for mat2 { fn to(((v11, v12, _, _), (v21, v22, _, _), _, _): mat4) -> Self { ((v11, v12), (v21, v22)) } } impl Cast> for mat2 { fn to(((v11, v12, _), (v21, v22, _), _): mat3) -> Self { ((v11, v12), (v21, v22)) } } impl> Cast> for mat3 { fn to(((v11, v12), (v21, v22)): mat2) -> Self { let (z, o) = <(T, T)>::to((0, 1)); ((v11, v12, z), (v21, v22, z), (z, z, o)) } } impl> Cast> for mat4 { fn to(((v11, v12), (v21, v22)): mat2) -> Self { let (z, o) = <(T, T)>::to((0, 1)); ((v11, v12, z, z), (v21, v22, z, z), (z, z, o, z), (z, z, z, o)) } } impl> Cast> for mat4 { fn to(((v11, v12, v13), (v21, v22, v23), (v31, v32, v33)): mat3) -> Self { let (z, o) = <(T, T)>::to((0, 1)); ((v11, v12, v13, z), (v21, v22, v23, z), (v31, v32, v33, z), (z, z, z, o)) } } pub trait FlattenCast { fn flatten(self) -> Vec; } impl FlattenCast for &[vec2] { fn flatten(self) -> Vec { self.iter().flat_map(|&(x, y)| [x, y]).collect() } } impl FlattenCast for &[vec3] { fn flatten(self) -> Vec { self.iter().flat_map(|&(x, y, z)| [x, y, z]).collect() } } impl FlattenCast for &[vec4] { fn flatten(self) -> Vec { self.iter().flat_map(|&(x, y, z, a)| [x, y, z, a]).collect() } } impl FlattenCast for vec2 { fn flatten(self) -> Vec { vec![self.0, self.1] } } impl FlattenCast for vec3 { fn flatten(self) -> Vec { vec![self.0, self.1, self.2] } } impl FlattenCast for vec4 { fn flatten(self) -> Vec { vec![self.0, self.1, self.2, self.3] } } pub trait FlattenCastMat { fn flatten_all(self) -> Vec; } impl> FlattenCastMat for vec2 { fn flatten_all(self) -> Vec { [self.0.flatten(), self.1.flatten()].concat() } } impl> FlattenCastMat for vec3 { fn flatten_all(self) -> Vec { [self.0.flatten(), self.1.flatten(), self.2.flatten()].concat() } } impl> FlattenCastMat for vec4 { fn flatten_all(self) -> Vec { [self.0.flatten(), self.1.flatten(), self.2.flatten(), self.3.flatten()].concat() } }