pub fn duplicate_vertices(&mut self) {
        fn duplicate<T: Copy>(values: &[T], indices: impl Iterator<Item = usize>) -> Vec<T> {
            indices.map(|i| values[i]).collect()
        }

        assert!(
            matches!(self.primitive_topology, PrimitiveTopology::TriangleList),
            "can only duplicate vertices for `TriangleList`s"
        );

        let indices = match self.indices.take() {
            Some(indices) => indices,
            None => return,
        };
        for (_, attributes) in self.attributes.iter_mut() {
            let indices = indices.iter();
            match attributes {
                VertexAttributeValues::Float32(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint32(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint32(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Float32x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Float32x3(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Float32x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(&vec, indices),
            }
        }
    }
/// Duplicates the vertex attributes so that no vertices are shared.
///
/// This can dramatically increase the vertex count, so make sure this is what you want.
/// Does nothing if no [Indices] are set.
Duplicates the vertex attributes so that no vertices are shared.
This can dramatically increase the vertex count, so make sure this is what you want.
Does nothing if no [Indices] are set.
Duplicates the vertex attributes so that no vertices are shared . This can dramatically increase the vertex count so make sure this is what you want . Does nothing if no [ Indices ] are set .
pub fn duplicate_vertices(&mut self) {
        fn duplicate<T: Copy>(values: &[T], indices: impl Iterator<Item = usize>) -> Vec<T> {
            indices.map(|i| values[i]).collect()
        }
        assert!(
            matches!(self.primitive_topology, PrimitiveTopology::TriangleList),
            "can only duplicate vertices for `TriangleList`s"
        );
        let indices = match self.indices.take() {
            Some(indices) => indices,
            None => return,
        };
        for (_, attributes) in self.attributes.iter_mut() {
            let indices = indices.iter();
            match attributes {
                VertexAttributeValues::Float32(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint32(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint32(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Float32x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Float32x3(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Float32x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(&vec, indices),
                VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(&vec, indices),
            }
        }
    }
pub fn duplicate_vertices ( & mut self ) { fn duplicate < T : Copy > ( values : & [ T ] , indices : impl Iterator < Item = usize > ) -> Vec < T > { indices . map ( | i | values [ i ] ) . collect ( ) } assert ! ( matches ( self primitive_topology PrimitiveTopology TriangleList ) " " ) ; let indices = match self . indices . take ( ) { Some ( indices ) => indices , None => return , } ; for ( _ , attributes ) in self . attributes . iter_mut ( ) { let indices = indices . iter ( ) ; match attributes { VertexAttributeValues :: Float32 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Sint32 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Uint32 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Float32x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Sint32x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Uint32x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Float32x3 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Sint32x3 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Uint32x3 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Sint32x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Uint32x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Float32x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Sint16x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Snorm16x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Uint16x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Unorm16x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Sint16x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Snorm16x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Uint16x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Unorm16x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Sint8x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Snorm8x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Uint8x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Unorm8x2 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Sint8x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Snorm8x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Uint8x4 ( vec ) => * vec = duplicate ( & vec , indices ) , VertexAttributeValues :: Unorm8x4 ( vec ) => * vec = duplicate ( & vec , indices ) , } } }
Duplicates the vertex attributes so that no vertices are shared.
Duplicates the vertex attributes so that no vertices are shared .
&mut self
&mut self