use crate::core::ColChar;
pub type Vec3D = glam::DVec3;
pub type Transform3D = glam::DMat4;
#[derive(Debug, Clone)]
pub struct Face {
pub v_indices: Vec<usize>,
pub fill_char: ColChar,
}
impl Face {
#[must_use]
pub const fn new(v_indices: Vec<usize>, fill_char: ColChar) -> Self {
Self {
v_indices,
fill_char,
}
}
pub fn index_into<T: Copy>(&self, vertices: &[T]) -> Result<Vec<T>, String> {
let mut indexed_vertices = Vec::new();
for v_index in &self.v_indices {
if let Some(vertex) = vertices.get(*v_index) {
indexed_vertices.push(*vertex);
} else {
return Err(format!(
"Mesh face vertex index ({}) is out of bounds ({})",
v_index,
vertices.len(),
));
}
}
Ok(indexed_vertices)
}
}