pub fn validate(&self) -> Result<(), MeshValidationError> {
        let position_length = self.vertex_positions.len();
        let indices_length = self.indices.len();

        if position_length == 0 {
            return Err(MeshValidationError::ZeroVertices);
        }

        if position_length > MAX_VERTEX_COUNT {
            return Err(MeshValidationError::ExceededMaxVertexCount { count: position_length });
        }

        let first_different_length = [
            (self.vertex_normals.len(), VertexBufferType::Normal),
            (self.vertex_tangents.len(), VertexBufferType::Tangent),
            (self.vertex_uv0.len(), VertexBufferType::Uv0),
            (self.vertex_uv1.len(), VertexBufferType::Uv1),
            (self.vertex_colors.len(), VertexBufferType::Colors),
            (self.vertex_material_indices.len(), VertexBufferType::MaterialIndices),
        ]
        .iter()
        .find_map(|&(len, ty)| if len != position_length { Some((len, ty)) } else { None });

        if let Some((len, ty)) = first_different_length {
            return Err(MeshValidationError::MismatchedVertexCount {
                ty,
                actual: len,
                expected: position_length,
            });
        }

        if indices_length == 0 {
            return Err(MeshValidationError::ZeroIndices);
        }

        if indices_length % 3 != 0 {
            return Err(MeshValidationError::IndexCountNotMultipleOfThree { count: indices_length });
        }

        let first_oob_index = self.indices.iter().enumerate().find_map(|(idx, &i)| {
            if (i as usize) >= position_length {
                Some((idx, i))
            } else {
                None
            }
        });

        if let Some((index, value)) = first_oob_index {
            return Err(MeshValidationError::IndexOutOfBounds {
                index,
                value,
                max: position_length,
            });
        }

        Ok(())
    }
/// Validates that all vertex attributes have the same length.
Validates that all vertex attributes have the same length.
Validates that all vertex attributes have the same length .
pub fn validate(&self) -> Result<(), MeshValidationError> {
        let position_length = self.vertex_positions.len();
        let indices_length = self.indices.len();
        if position_length == 0 {
            return Err(MeshValidationError::ZeroVertices);
        }
        if position_length > MAX_VERTEX_COUNT {
            return Err(MeshValidationError::ExceededMaxVertexCount { count: position_length });
        }
        let first_different_length = [
            (self.vertex_normals.len(), VertexBufferType::Normal),
            (self.vertex_tangents.len(), VertexBufferType::Tangent),
            (self.vertex_uv0.len(), VertexBufferType::Uv0),
            (self.vertex_uv1.len(), VertexBufferType::Uv1),
            (self.vertex_colors.len(), VertexBufferType::Colors),
            (self.vertex_material_indices.len(), VertexBufferType::MaterialIndices),
        ]
        .iter()
        .find_map(|&(len, ty)| if len != position_length { Some((len, ty)) } else { None });
        if let Some((len, ty)) = first_different_length {
            return Err(MeshValidationError::MismatchedVertexCount {
                ty,
                actual: len,
                expected: position_length,
            });
        }
        if indices_length == 0 {
            return Err(MeshValidationError::ZeroIndices);
        }
        if indices_length % 3 != 0 {
            return Err(MeshValidationError::IndexCountNotMultipleOfThree { count: indices_length });
        }
        let first_oob_index = self.indices.iter().enumerate().find_map(|(idx, &i)| {
            if (i as usize) >= position_length {
                Some((idx, i))
            } else {
                None
            }
        });
        if let Some((index, value)) = first_oob_index {
            return Err(MeshValidationError::IndexOutOfBounds {
                index,
                value,
                max: position_length,
            });
        }
        Ok(())
    }
pub fn validate ( & self ) -> Result < ( ) , MeshValidationError > { let position_length = self . vertex_positions . len ( ) ; let indices_length = self . indices . len ( ) ; if position_length == 0 { return Err ( MeshValidationError :: ZeroVertices ) ; } if position_length > MAX_VERTEX_COUNT { return Err ( MeshValidationError :: ExceededMaxVertexCount { count : position_length } ) ; } let first_different_length = [ ( self . vertex_normals . len ( ) , VertexBufferType :: Normal ) , ( self . vertex_tangents . len ( ) , VertexBufferType :: Tangent ) , ( self . vertex_uv0 . len ( ) , VertexBufferType :: Uv0 ) , ( self . vertex_uv1 . len ( ) , VertexBufferType :: Uv1 ) , ( self . vertex_colors . len ( ) , VertexBufferType :: Colors ) , ( self . vertex_material_indices . len ( ) , VertexBufferType :: MaterialIndices ) , ] . iter ( ) . find_map ( | & ( len , ty ) | if len != position_length { Some ( ( len , ty ) ) } else { None } ) ; if let Some ( ( len , ty ) ) = first_different_length { return Err ( MeshValidationError :: MismatchedVertexCount { ty , actual : len , expected : position_length , } ) ; } if indices_length == 0 { return Err ( MeshValidationError :: ZeroIndices ) ; } if indices_length % 3 != 0 { return Err ( MeshValidationError :: IndexCountNotMultipleOfThree { count : indices_length } ) ; } let first_oob_index = self . indices . iter ( ) . enumerate ( ) . find_map ( | ( idx , & i ) | { if ( i as usize ) >= position_length { Some ( ( idx , i ) ) } else { None } } ) ; if let Some ( ( index , value ) ) = first_oob_index { return Err ( MeshValidationError :: IndexOutOfBounds { index , value , max : position_length , } ) ; } Ok ( ( ) ) }
Validates that all vertex attributes have the same length.
Validates that all vertex attributes have the same length .
&self
&self