///
/// Returns an error if the mesh is not valid.
///
Returns an error if the mesh is not valid.
Returns an error if the mesh is not valid .
pub fn validate(&self) -> Result<()> {
        let vertex_count = if let Some(ref indices) = self.indices {
            let index_count = match indices {
                Indices::U8(ind) => ind.len(),
                Indices::U16(ind) => ind.len(),
                Indices::U32(ind) => ind.len(),
            };
            if index_count % 3 != 0 {
                Err(Error::InvalidNumberOfVertices(index_count))?;
            }
            match indices {
                Indices::U8(ind) => ind.iter().max().map(|m| m + 1).unwrap_or(0) as usize,
                Indices::U16(ind) => ind.iter().max().map(|m| m + 1).unwrap_or(0) as usize,
                Indices::U32(ind) => ind.iter().max().map(|m| m + 1).unwrap_or(0) as usize,
            }
        } else {
            let vertex_count = self.positions.len();
            if vertex_count % 3 != 0 {
                Err(Error::InvalidNumberOfVertices(vertex_count))?;
            }
            vertex_count
        };
        let buffer_check = |length: Option<usize>, name: &str| -> Result<()> {
            if let Some(length) = length {
                if length < vertex_count {
                    Err(Error::InvalidBufferLength(
                        name.to_string(),
                        vertex_count,
                        length,
                    ))?;
                }
            }
            Ok(())
        };
        buffer_check(Some(self.positions.len()), "position")?;
        buffer_check(self.normals.as_ref().map(|b| b.len()), "normal")?;
        buffer_check(self.tangents.as_ref().map(|b| b.len()), "tangent")?;
        buffer_check(self.colors.as_ref().map(|b| b.len()), "color")?;
        buffer_check(self.uvs.as_ref().map(|b| b.len()), "uv coordinate")?;
        Ok(())
    }
pub fn validate ( & self ) -> Result < ( ) > { let vertex_count = if let Some ( ref indices ) = self . indices { let index_count = match indices { Indices :: U8 ( ind ) => ind . len ( ) , Indices :: U16 ( ind ) => ind . len ( ) , Indices :: U32 ( ind ) => ind . len ( ) , } ; if index_count % 3 != 0 { Err ( Error :: InvalidNumberOfVertices ( index_count ) ) ? ; } match indices { Indices :: U8 ( ind ) => ind . iter ( ) . max ( ) . map ( | m | m + 1 ) . unwrap_or ( 0 ) as usize , Indices :: U16 ( ind ) => ind . iter ( ) . max ( ) . map ( | m | m + 1 ) . unwrap_or ( 0 ) as usize , Indices :: U32 ( ind ) => ind . iter ( ) . max ( ) . map ( | m | m + 1 ) . unwrap_or ( 0 ) as usize , } } else { let vertex_count = self . positions . len ( ) ; if vertex_count % 3 != 0 { Err ( Error :: InvalidNumberOfVertices ( vertex_count ) ) ? ; } vertex_count } ; let buffer_check = | length : Option < usize > , name : & str | -> Result < ( ) > { if let Some ( length ) = length { if length < vertex_count { Err ( Error :: InvalidBufferLength ( name . to_string ( ) , vertex_count , length , ) ) ? ; } } Ok ( ( ) ) } ; buffer_check ( Some ( self . positions . len ( ) ) , " " ) ? ; buffer_check ( self . normals . as_ref ( ) . map ( | b | b . len ( ) ) , " " ) ? ; buffer_check ( self . tangents . as_ref ( ) . map ( | b | b . len ( ) ) , " " ) ? ; buffer_check ( self . colors . as_ref ( ) . map ( | b | b . len ( ) ) , " " ) ? ; buffer_check ( self . uvs . as_ref ( ) . map ( | b | b . len ( ) ) , " " ) ? ; Ok ( ( ) ) }
Returns an error if the mesh is not valid.
Returns an error if the mesh is not valid .
&self