Debian Codegraph @

debian/missing-sources/glam-0.16.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.16.0 core/sse2/::floatrust-analyzer cargo glam 0.16.0 core/sse2/float/::*;
7 use craterust-analyzer cargo glam 0.16.0 crate/::const_m128rust-analyzer cargo glam 0.16.0 macros/const_m128!;
8 use craterust-analyzer cargo glam 0.16.0 crate/::corerust-analyzer cargo glam 0.16.0 core/::{
9 storagerust-analyzer cargo glam 0.16.0 core/storage/::XYZrust-analyzer cargo glam 0.16.0 core/storage/XYZ#,
10 traitsrust-analyzer cargo glam 0.16.0 core/traits/::{quaternionrust-analyzer cargo glam 0.16.0 core/traits/quaternion/::Quaternionrust-analyzer cargo glam 0.16.0 core/traits/quaternion/Quaternion#, scalarrust-analyzer cargo glam 0.16.0 core/traits/scalar/::*, vectorrust-analyzer cargo glam 0.16.0 core/traits/vector/::*},
11 };
12
13 impl Quaternionrust-analyzer cargo glam 0.16.0 core/traits/quaternion/Quaternion#<f32> for __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# {
14 type SIMDVector3rust-analyzer cargo glam 0.16.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#;
15
16 #[inline(always)]
17 fn conjugaterust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]conjugate().(self) -> Selfrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`] {
18 const SIGNrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/SIGN.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_m128rust-analyzer cargo glam 0.16.0 macros/const_m128!!([-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]);
19 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.16.0 core/sse2/quaternion/SIGN.) }
20 }
21
22 #[inline]
23 fn lerprust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]lerp().(self, end: Selfrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`], s: f32) -> Selfrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`] {
24 glam_assertrust-analyzer cargo glam 0.16.0 macros/glam_assert!!(FloatVector4::is_normalized(self));
25 glam_assertrust-analyzer cargo glam 0.16.0 macros/glam_assert!!(FloatVector4::is_normalized(end));
26
27 unsafe {
28 const NEG_ZEROrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/NEG_ZERO.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_m128rust-analyzer cargo glam 0.16.0 macros/const_m128!!([-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().0.0; 4]);
29 let start = self;
30 let end = end;
31 let dot = Vector4rust-analyzer cargo glam 0.16.0 core/traits/vector/Vector4#::dot_into_vecrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector4<f32>`]dot_into_vec().(start, end);
32 // Calculate the bias, if the dot product is positive or zero, there is no bias
33 // but if it is negative, we want to flip the 'end' rotation XYZW components
34 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.16.0 core/sse2/quaternion/NEG_ZERO.);
35 let interpolated = _mm_add_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_add_ps().(
36 _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)),
37 start,
38 );
39 FloatVector4rust-analyzer cargo glam 0.16.0 core/traits/vector/FloatVector4#::normalizerust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`FloatVector4<f32>`]normalize().(interpolated)
40 }
41 }
42
43 #[inline]
44 fn slerprust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]slerp().(self, end: Selfrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`], s: f32) -> Selfrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`] {
45 // http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
46 glam_assertrust-analyzer cargo glam 0.16.0 macros/glam_assert!!(FloatVector4::is_normalized(self));
47 glam_assertrust-analyzer cargo glam 0.16.0 macros/glam_assert!!(FloatVector4::is_normalized(end));
48
49 const DOT_THRESHOLDrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/DOT_THRESHOLD.: f32 = 0.9995;
50
51 let dot = Vector4rust-analyzer cargo glam 0.16.0 core/traits/vector/Vector4#::dotrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector4<f32>`]dot().(self, end);
52
53 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.16.0 core/sse2/quaternion/DOT_THRESHOLD. {
54 // assumes lerp returns a normalized quaternion
55 self.lerprust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]lerp().(end, s)
56 } else {
57 // assumes scalar_acos clamps the input to [-1.0, 1.0]
58 let theta = dot.acos_approxrust-analyzer cargo glam 0.16.0 core/traits/scalar/impl#[f32][FloatEx]acos_approx().();
59
60 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;
61 let y = s;
62 let z = 1.0;
63
64 unsafe {
65 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));
66 let tmp = m128_sinrust-analyzer cargo glam 0.16.0 core/sse2/float/m128_sin().(tmp);
67
68 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);
69 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);
70 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);
71
72 self.mulrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(scale1).addrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]add().(end.mulrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(scale2)).divrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]div().(theta_sin)
73 }
74 }
75 }
76
77 #[inline]
78 fn mul_quaternionrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]mul_quaternion().(self, other: Selfrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]) -> Selfrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`] {
79 unsafe {
80 // Based on https://github.com/nfrechette/rtm `rtm::quat_mul`
81 let lhs = self;
82 let rhs = other;
83
84 const CONTROL_WZYXrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/CONTROL_WZYX.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_m128rust-analyzer cargo glam 0.16.0 macros/const_m128!!([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]);
85 const CONTROL_ZWXYrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/CONTROL_ZWXY.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_m128rust-analyzer cargo glam 0.16.0 macros/const_m128!!([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]);
86 const CONTROL_YXWZrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/CONTROL_YXWZ.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_m128rust-analyzer cargo glam 0.16.0 macros/const_m128!!([-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]);
87
88 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);
89 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);
90 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);
91 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);
92
93 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);
94 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);
95
96 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);
97 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);
98
99 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.16.0 core/sse2/quaternion/CONTROL_WZYX.);
100
101 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);
102 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);
103
104 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.16.0 core/sse2/quaternion/CONTROL_ZWXY.);
105
106 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);
107 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);
108
109 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.16.0 core/sse2/quaternion/CONTROL_YXWZ.);
110 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);
111 _mm_add_psrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/sse/_mm_add_ps().(result0, result1)
112 }
113 }
114
115 #[inline]
116 fn mul_vector3rust-analyzer cargo glam 0.16.0 core/sse2/quaternion/impl#[__m128][`Quaternion<f32>`]mul_vector3().(self, other: XYZrust-analyzer cargo glam 0.16.0 core/storage/XYZ#<f32>) -> XYZrust-analyzer cargo glam 0.16.0 core/storage/XYZ#<f32> {
117 self.mul_float4_as_vector3rust-analyzer cargo glam 0.16.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().()
118 }
119
120 #[inline]
121 fn mul_float4_as_vector3rust-analyzer cargo glam 0.16.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# {
122 glam_assertrust-analyzer cargo glam 0.16.0 macros/glam_assert!!(FloatVector4::is_normalized(self));
123 unsafe {
124 const TWOrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/TWO.: __m128rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_arch/x86/__m128# = const_m128rust-analyzer cargo glam 0.16.0 macros/const_m128!!([2.0; 4]);
125 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);
126 let b = self;
127 let b2 = Vector3rust-analyzer cargo glam 0.16.0 core/traits/vector/Vector3#::dot_into_vecrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector3<f32>`]dot_into_vec().(b, b);
128 other
129 .mulrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(w.mulrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(w).subrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]sub().(b2))
130 .addrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]add().(b.mulrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(Vector3rust-analyzer cargo glam 0.16.0 core/traits/vector/Vector3#::dot_into_vecrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector3<f32>`]dot_into_vec().(other, b).mulrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(TWOrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/TWO.)))
131 .addrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]add().(b.crossrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector3<f32>`]cross().(other).mulrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(w.mulrust-analyzer cargo glam 0.16.0 core/sse2/vector/impl#[__m128][`Vector<f32>`]mul().(TWOrust-analyzer cargo glam 0.16.0 core/sse2/quaternion/TWO.)))
132 }
133 }
134 }