Debian Codegraph @

debian/missing-sources/glam-0.19.0/src/core/sse2/quaternion.rs

raw symbols SCIP
1 #[cfg(target_arch = "x86")]
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::archrust-analyzer cargo core https://github.com/rust-lang/rust/library/core arch/::x86::*;
3 #[cfg(target_arch = "x86_64")]
4 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::archrust-analyzer cargo core https://github.com/rust-lang/rust/library/core arch/::x86_64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/arch/x86_64/::*;
5
6 use superrust-analyzer cargo glam 0.19.0 core/sse2/::floatrust-analyzer cargo glam 0.19.0 core/sse2/float/::*;
7 use craterust-analyzer cargo glam 0.19.0 crate/::corerust-analyzer cargo glam 0.19.0 core/::{
8 storagerust-analyzer cargo glam 0.19.0 core/storage/::XYZrust-analyzer cargo glam 0.19.0 core/storage/XYZ#,
9 traitsrust-analyzer cargo glam 0.19.0 core/traits/::{quaternionrust-analyzer cargo glam 0.19.0 core/traits/quaternion/::Quaternionrust-analyzer cargo glam 0.19.0 core/traits/quaternion/Quaternion#, scalarrust-analyzer cargo glam 0.19.0 core/traits/scalar/::*, vectorrust-analyzer cargo glam 0.19.0 core/traits/vector/::*},
10 };
11
12 impl Quaternionrust-analyzer cargo glam 0.19.0 core/traits/quaternion/Quaternion#<f32> for __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# {
13 type SIMDVector3rust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]SIMDVector3# = __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128#;
14
15 #[inline(always)]
16 fn conjugaterust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]conjugate().(self) -> Selfrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`] {
17 const SIGNrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/SIGN.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_f32x4rust-analyzer cargo glam 0.19.0 macros/const_f32x4!!([-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().0.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().0.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().0.0, 0.0]);
18 unsafe { _mm_xor_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_xor_ps().(self, SIGNrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/SIGN.) }
19 }
20
21 #[inline]
22 fn lerprust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]lerp().(self, end: Selfrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`], s: f32) -> Selfrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`] {
23 glam_assertrust-analyzer cargo glam 0.19.0 macros/glam_assert!!(FloatVector4::is_normalized(self));
24 glam_assertrust-analyzer cargo glam 0.19.0 macros/glam_assert!!(FloatVector4::is_normalized(end));
25
26 unsafe {
27 const NEG_ZEROrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/NEG_ZERO.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_f32x4rust-analyzer cargo glam 0.19.0 macros/const_f32x4!!([-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().0.0; 4]);
28 let start = self;
29 let end = end;
30 let dot = Vector4rust-analyzer cargo glam 0.19.0 core/traits/vector/Vector4#::dot_into_vecrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector4<f32>`]dot_into_vec().(start, end);
31 // Calculate the bias, if the dot product is positive or zero, there is no bias
32 // but if it is negative, we want to flip the 'end' rotation XYZW components
33 let bias = _mm_and_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_and_ps().(dot, NEG_ZEROrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/NEG_ZERO.);
34 let interpolated = _mm_add_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_add_ps().(
35 _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(_mm_sub_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_sub_ps().(_mm_xor_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_xor_ps().(end, bias), start), _mm_set_ps1rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_set_ps1().(s)),
36 start,
37 );
38 FloatVector4rust-analyzer cargo glam 0.19.0 core/traits/vector/FloatVector4#::normalizerust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`FloatVector4<f32>`]normalize().(interpolated)
39 }
40 }
41
42 #[inline]
43 fn slerprust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]slerp().(self, end: Selfrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`], s: f32) -> Selfrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`] {
44 // http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
45 glam_assertrust-analyzer cargo glam 0.19.0 macros/glam_assert!!(FloatVector4::is_normalized(self));
46 glam_assertrust-analyzer cargo glam 0.19.0 macros/glam_assert!!(FloatVector4::is_normalized(end));
47
48 const DOT_THRESHOLDrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/DOT_THRESHOLD.: f32 = 0.9995;
49
50 let dot = Vector4rust-analyzer cargo glam 0.19.0 core/traits/vector/Vector4#::dotrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector4<f32>`]dot().(self, end);
51
52 if dot rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt().DOT_THRESHOLDrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/DOT_THRESHOLD. {
53 // assumes lerp returns a normalized quaternion
54 self.lerprust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]lerp().(end, s)
55 } else {
56 // assumes scalar_acos clamps the input to [-1.0, 1.0]
57 let theta = dot.acos_approxrust-analyzer cargo glam 0.19.0 core/traits/scalar/impl#[f32][FloatEx]acos_approx().();
58
59 let x = 1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().s;
60 let y = s;
61 let z = 1.0;
62
63 unsafe {
64 let tmp = _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(_mm_set_ps1rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_set_ps1().(theta), _mm_set_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_set_ps().(0.0, z, y, x));
65 let tmp = m128_sinrust-analyzer cargo glam 0.19.0 core/sse2/float/m128_sin().(tmp);
66
67 let scale1 = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(tmp, tmp, 0b00_00_00_00);
68 let scale2 = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(tmp, tmp, 0b01_01_01_01);
69 let theta_sin = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(tmp, tmp, 0b10_10_10_10);
70
71 self.mulrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(scale1).addrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]add().(end.mulrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(scale2)).divrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]div().(theta_sin)
72 }
73 }
74 }
75
76 #[inline]
77 fn mul_quaternionrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]mul_quaternion().(self, other: Selfrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]) -> Selfrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`] {
78 glam_assertrust-analyzer cargo glam 0.19.0 macros/glam_assert!!(FloatVector4::is_normalized(self));
79 glam_assertrust-analyzer cargo glam 0.19.0 macros/glam_assert!!(FloatVector4::is_normalized(other));
80 unsafe {
81 // Based on https://github.com/nfrechette/rtm `rtm::quat_mul`
82 let lhs = self;
83 let rhs = other;
84
85 const CONTROL_WZYXrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/CONTROL_WZYX.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_f32x4rust-analyzer cargo glam 0.19.0 macros/const_f32x4!!([1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1.0, 1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1.0]);
86 const CONTROL_ZWXYrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/CONTROL_ZWXY.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_f32x4rust-analyzer cargo glam 0.19.0 macros/const_f32x4!!([1.0, 1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1.0]);
87 const CONTROL_YXWZrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/CONTROL_YXWZ.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_f32x4rust-analyzer cargo glam 0.19.0 macros/const_f32x4!!([-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1.0, 1.0, 1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1.0]);
88
89 let r_xxxx = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(lhs, lhs, 0b00_00_00_00);
90 let r_yyyy = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(lhs, lhs, 0b01_01_01_01);
91 let r_zzzz = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(lhs, lhs, 0b10_10_10_10);
92 let r_wwww = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(lhs, lhs, 0b11_11_11_11);
93
94 let lxrw_lyrw_lzrw_lwrw = _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(r_wwww, rhs);
95 let l_wzyx = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(rhs, rhs, 0b00_01_10_11);
96
97 let lwrx_lzrx_lyrx_lxrx = _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(r_xxxx, l_wzyx);
98 let l_zwxy = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(l_wzyx, l_wzyx, 0b10_11_00_01);
99
100 let lwrx_nlzrx_lyrx_nlxrx = _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(lwrx_lzrx_lyrx_lxrx, CONTROL_WZYXrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/CONTROL_WZYX.);
101
102 let lzry_lwry_lxry_lyry = _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(r_yyyy, l_zwxy);
103 let l_yxwz = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(l_zwxy, l_zwxy, 0b00_01_10_11);
104
105 let lzry_lwry_nlxry_nlyry = _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(lzry_lwry_lxry_lyry, CONTROL_ZWXYrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/CONTROL_ZWXY.);
106
107 let lyrz_lxrz_lwrz_lzrz = _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(r_zzzz, l_yxwz);
108 let result0 = _mm_add_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_add_ps().(lxrw_lyrw_lzrw_lwrw, lwrx_nlzrx_lyrx_nlxrx);
109
110 let nlyrz_lxrz_lwrz_wlzrz = _mm_mul_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_mul_ps().(lyrz_lxrz_lwrz_lzrz, CONTROL_YXWZrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/CONTROL_YXWZ.);
111 let result1 = _mm_add_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_add_ps().(lzry_lwry_nlxry_nlyry, nlyrz_lxrz_lwrz_wlzrz);
112 _mm_add_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_add_ps().(result0, result1)
113 }
114 }
115
116 #[inline]
117 fn mul_vector3rust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]mul_vector3().(self, other: XYZrust-analyzer cargo glam 0.19.0 core/storage/XYZ#<f32>) -> XYZrust-analyzer cargo glam 0.19.0 core/storage/XYZ#<f32> {
118 self.mul_float4_as_vector3rust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]mul_float4_as_vector3().(other.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
119 }
120
121 #[inline]
122 fn mul_float4_as_vector3rust-analyzer cargo glam 0.19.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]mul_float4_as_vector3().(self, other: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128#) -> __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# {
123 glam_assertrust-analyzer cargo glam 0.19.0 macros/glam_assert!!(FloatVector4::is_normalized(self));
124 unsafe {
125 const TWOrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/TWO.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_f32x4rust-analyzer cargo glam 0.19.0 macros/const_f32x4!!([2.0; 4]);
126 let w = _mm_shuffle_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_shuffle_ps().(self, self, 0b11_11_11_11);
127 let b = self;
128 let b2 = Vector3rust-analyzer cargo glam 0.19.0 core/traits/vector/Vector3#::dot_into_vecrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector3<f32>`]dot_into_vec().(b, b);
129 other
130 .mulrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(w.mulrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(w).subrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]sub().(b2))
131 .addrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]add().(b.mulrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(Vector3rust-analyzer cargo glam 0.19.0 core/traits/vector/Vector3#::dot_into_vecrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector3<f32>`]dot_into_vec().(other, b).mulrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(TWOrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/TWO.)))
132 .addrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]add().(b.crossrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector3<f32>`]cross().(other).mulrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(w.mulrust-analyzer cargo glam 0.19.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(TWOrust-analyzer cargo glam 0.19.0 core/sse2/quaternion/TWO.)))
133 }
134 }
135 }