use crate::error::Error;
use super::{primitives::Primitives, vertices::Vertices};
pub struct Mesh {
vertices: Vertices,
primitives: Primitives,
}
impl Mesh {
pub fn new(vertices: Vertices, primitives: Primitives) -> Result<Self, Error> {
match primitives.max_index() {
Some(m) => {
if m as usize >= vertices.len() {
return Err(Error::Indices(format!(
"Indices reference vertex {}, but only got {} vertices",
m,
vertices.len()
)));
}
}
None => {}
}
Ok(Self {
vertices,
primitives,
})
}
pub fn get_vertices(&self) -> &Vertices {
&self.vertices
}
pub fn get_primitives(&self) -> &Primitives {
&self.primitives
}
}