// pathfinder/simd/src/extras.rs // // Copyright © 2019 The Pathfinder Project Developers. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use crate::default::{F32x4, U32x4}; impl F32x4 { // Accessors #[inline] pub fn x(self) -> f32 { self[0] } #[inline] pub fn y(self) -> f32 { self[1] } #[inline] pub fn z(self) -> f32 { self[2] } #[inline] pub fn w(self) -> f32 { self[3] } // Mutators #[inline] pub fn set_x(&mut self, x: f32) { self[0] = x } #[inline] pub fn set_y(&mut self, y: f32) { self[1] = y } #[inline] pub fn set_z(&mut self, z: f32) { self[2] = z } #[inline] pub fn set_w(&mut self, w: f32) { self[3] = w } // Comparisons #[inline] pub fn approx_eq(self, other: F32x4, epsilon: f32) -> bool { (self - other) .abs() .packed_gt(F32x4::splat(epsilon)) .is_all_zeroes() } }