pub fn transform(&mut self, transform: &Mat4) -> Result<()> {
        match self.positions {
            Positions::F32(ref mut positions) => {
                for pos in positions.iter_mut() {
                    *pos = (transform * pos.extend(1.0)).truncate();
                }
            }
            Positions::F64(ref mut positions) => {
                let t = transform.cast::<f64>().unwrap();
                for pos in positions.iter_mut() {
                    *pos = (t * pos.extend(1.0)).truncate();
                }
            }
        };

        if self.normals.is_some() || self.tangents.is_some() {
            let normal_transform = transform
                .invert()
                .ok_or(Error::FailedInvertingTransformationMatrix)?
                .transpose();

            if let Some(ref mut normals) = self.normals {
                for n in normals.iter_mut() {
                    *n = (normal_transform * n.extend(1.0)).truncate();
                }
            }
            if let Some(ref mut tangents) = self.tangents {
                for t in tangents.iter_mut() {
                    *t = (normal_transform * t.truncate().extend(1.0))
                        .truncate()
                        .extend(t.w);
                }
            }
        }
        Ok(())
    }
///
/// Transforms the mesh by the given transformation.
///
Transforms the mesh by the given transformation.
Transforms the mesh by the given transformation .
pub fn transform(&mut self, transform: &Mat4) -> Result<()> {
        match self.positions {
            Positions::F32(ref mut positions) => {
                for pos in positions.iter_mut() {
                    *pos = (transform * pos.extend(1.0)).truncate();
                }
            }
            Positions::F64(ref mut positions) => {
                let t = transform.cast::<f64>().unwrap();
                for pos in positions.iter_mut() {
                    *pos = (t * pos.extend(1.0)).truncate();
                }
            }
        };
        if self.normals.is_some() || self.tangents.is_some() {
            let normal_transform = transform
                .invert()
                .ok_or(Error::FailedInvertingTransformationMatrix)?
                .transpose();
            if let Some(ref mut normals) = self.normals {
                for n in normals.iter_mut() {
                    *n = (normal_transform * n.extend(1.0)).truncate();
                }
            }
            if let Some(ref mut tangents) = self.tangents {
                for t in tangents.iter_mut() {
                    *t = (normal_transform * t.truncate().extend(1.0))
                        .truncate()
                        .extend(t.w);
                }
            }
        }
        Ok(())
    }
pub fn transform ( & mut self , transform : & Mat4 ) -> Result < ( ) > { match self . positions { Positions :: F32 ( ref mut positions ) => { for pos in positions . iter_mut ( ) { * pos = ( transform * pos . extend ( 1.0 ) ) . truncate ( ) ; } } Positions :: F64 ( ref mut positions ) => { let t = transform . cast :: < f64 > ( ) . unwrap ( ) ; for pos in positions . iter_mut ( ) { * pos = ( t * pos . extend ( 1.0 ) ) . truncate ( ) ; } } } ; if self . normals . is_some ( ) || self . tangents . is_some ( ) { let normal_transform = transform . invert ( ) . ok_or ( Error :: FailedInvertingTransformationMatrix ) ? . transpose ( ) ; if let Some ( ref mut normals ) = self . normals { for n in normals . iter_mut ( ) { * n = ( normal_transform * n . extend ( 1.0 ) ) . truncate ( ) ; } } if let Some ( ref mut tangents ) = self . tangents { for t in tangents . iter_mut ( ) { * t = ( normal_transform * t . truncate ( ) . extend ( 1.0 ) ) . truncate ( ) . extend ( t . w ) ; } } } Ok ( ( ) ) }
Transforms the mesh by the given transformation.
Transforms the mesh by the given transformation .
&mut self
transform
&Mat4
&mut self
transform
&Mat4