2019-02-01 19:58:35 -05:00
|
|
|
// pathfinder/simd/src/extras.rs
|
|
|
|
//
|
|
|
|
// Copyright © 2019 The Pathfinder Project Developers.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2019-02-05 13:03:20 -05:00
|
|
|
use crate::default::{F32x4, U32x4};
|
2019-02-01 19:58:35 -05:00
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|