Skip to content

Commit

Permalink
Removed debug assert from Quat::new.
Browse files Browse the repository at this point in the history
Need to rethink this approach.
  • Loading branch information
bitshifter committed Jul 5, 2019
1 parent 50acac0 commit bc15fde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/f32/glam_mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,18 @@ mod test {

#[test]
fn test_quaternion() {
use crate::{deg, Quat, Vec3};
let g = Quat::from_axis_angle(Vec3::new(1.0, 2.0, 3.0).normalize(), deg(270.0));
let m = mint::Quaternion::from(g);
use crate::Quat;
let m = mint::Quaternion {
v: mint::Vector3 {
x: 1.0,
y: 2.0,
z: 3.0,
},
s: 4.0,
};
let g = Quat::from(m);
assert_eq!(g, Quat::from((1.0, 2.0, 3.0, 4.0)));
assert_eq!(m, g.into());
assert_eq!(g, m.into());
}

#[test]
Expand Down
9 changes: 6 additions & 3 deletions src/f32/quat_sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ pub struct Quat(pub(crate) __m128);
impl Quat {
/// Creates a new rotation quaternion.
///
/// # Preconditions
/// This should generally not be called manually unless you know what you are doing. Use one of
/// the other constructors instead such as `identity` or `from_axis_angle`.
///
/// The input must represent a quaternion of unit length.
/// `new` is mostly used by unit tests and `serde` deserialization.
#[inline]
pub fn new(x: f32, y: f32, z: f32, w: f32) -> Self {
let q = unsafe { Self(_mm_set_ps(w, z, y, x)) };
debug_assert!(q.is_normalized());
// might be better as a warning - if this asserts during deserialization it's really
// obtuse.
// debug_assert!(q.is_normalized());
q
}

Expand Down

0 comments on commit bc15fde

Please sign in to comment.