1#![deny(non_camel_case_types)]
11#![deny(unused_parens)]
12#![deny(non_upper_case_globals)]
13#![deny(unused_results)]
14#![deny(unused_qualifications)]
15#![warn(missing_docs)]
16#![warn(unused_imports)]
17#![allow(missing_copy_implementations)]
18#![allow(clippy::too_many_arguments)] #![allow(clippy::module_inception)]
20#![allow(clippy::manual_range_contains)] #![allow(clippy::type_complexity)] #![doc(html_root_url = "http://docs.rs/parry/0.1.1")]
23#![no_std]
24
25#[cfg(all(
26 feature = "simd-is-enabled",
27 not(feature = "simd-stable"),
28 not(feature = "simd-nightly")
29))]
30std::compile_error!("The `simd-is-enabled` feature should not be enabled explicitly. Please enable the `simd-stable` or the `simd-nightly` feature instead.");
31#[cfg(all(feature = "simd-is-enabled", feature = "enhanced-determinism"))]
32std::compile_error!(
33 "SIMD cannot be enabled when the `enhanced-determinism` feature is also enabled."
34);
35
36#[cfg(feature = "simd-is-enabled")]
37macro_rules! array(
38 ($callback: expr; SIMD_WIDTH) => {
39 {
40 #[inline(always)]
41 #[allow(dead_code)]
42 fn create_arr<T>(mut callback: impl FnMut(usize) -> T) -> [T; SIMD_WIDTH] {
43 #[cfg(not(feature = "simd-is-enabled"))]
44 return [callback(0usize)];
45 #[cfg(feature = "simd-is-enabled")]
46 return [callback(0usize), callback(1usize), callback(2usize), callback(3usize)];
47 }
48
49 create_arr($callback)
50 }
51 }
52);
53
54#[cfg(feature = "std")]
55extern crate std;
56
57#[cfg(feature = "alloc")]
58#[cfg_attr(test, macro_use)]
59extern crate alloc;
60
61#[cfg(feature = "serde")]
62#[macro_use]
63extern crate serde;
64#[macro_use]
65extern crate approx;
66extern crate num_traits as num;
67
68pub extern crate either;
69pub extern crate nalgebra as na;
70pub extern crate simba;
71
72pub mod bounding_volume;
73pub mod mass_properties;
74pub mod partitioning;
75pub mod query;
76pub mod shape;
77#[cfg(feature = "alloc")]
78pub mod transformation;
79pub mod utils;
80
81mod real {
82 #[cfg(feature = "f64")]
84 pub use f64 as Real;
85
86 #[cfg(feature = "f32")]
88 pub use f32 as Real;
89}
90
91#[cfg(feature = "dim3")]
93pub mod math {
94 pub use super::real::*;
95 pub use super::simd::*;
96 use na::{
97 Isometry3, Matrix3, Point3, Translation3, UnitQuaternion, UnitVector3, Vector3, Vector6,
98 U3, U6,
99 };
100
101 pub const DEFAULT_EPSILON: Real = Real::EPSILON;
103
104 pub const DIM: usize = 3;
106
107 pub const TWO_DIM: usize = DIM * 2;
109
110 pub type Dim = U3;
112
113 pub type SpatialDim = U6;
115
116 pub type AngDim = U3;
118
119 pub type Point<N> = Point3<N>;
121
122 pub type AngVector<N> = Vector3<N>;
124
125 pub type Vector<N> = Vector3<N>;
127
128 pub type UnitVector<N> = UnitVector3<N>;
130
131 pub type Matrix<N> = Matrix3<N>;
133
134 pub type SpatialVector<N> = Vector6<N>;
136
137 pub type Orientation<N> = Vector3<N>;
139
140 pub type Isometry<N> = Isometry3<N>;
142
143 pub type Rotation<N> = UnitQuaternion<N>;
145
146 pub type Translation<N> = Translation3<N>;
148
149 pub type AngularInertia<N> = crate::utils::SdpMatrix3<N>;
151
152 pub type PrincipalAngularInertia<N> = Vector3<N>;
154
155 pub type CrossMatrix<N> = Matrix3<N>;
157
158 pub type SpacialVector<N> = Vector6<N>;
160
161 pub type SdpMatrix<N> = crate::utils::SdpMatrix3<N>;
163}
164
165#[cfg(feature = "dim2")]
167pub mod math {
168 pub use super::real::*;
169 pub use super::simd::*;
170 use na::{
171 Isometry2, Matrix2, Point2, Translation2, UnitComplex, UnitVector2, Vector1, Vector2,
172 Vector3, U1, U2,
173 };
174
175 pub const DEFAULT_EPSILON: Real = Real::EPSILON;
177
178 pub const DIM: usize = 2;
180
181 pub const TWO_DIM: usize = DIM * 2;
183
184 pub type Dim = U2;
186
187 pub type AngDim = U1;
189
190 pub type Point<N> = Point2<N>;
192
193 pub type AngVector<N> = N;
195
196 pub type Vector<N> = Vector2<N>;
198
199 pub type UnitVector<N> = UnitVector2<N>;
201
202 pub type Matrix<N> = Matrix2<N>;
204
205 pub type Orientation<N> = Vector1<N>;
207
208 pub type Isometry<N> = Isometry2<N>;
210
211 pub type Rotation<N> = UnitComplex<N>;
213
214 pub type Translation<N> = Translation2<N>;
216
217 pub type AngularInertia<N> = N;
219
220 pub type PrincipalAngularInertia<N> = N;
222
223 pub type CrossMatrix<N> = Vector2<N>;
225
226 pub type SpacialVector<N> = Vector3<N>;
228
229 pub type SdpMatrix<N> = crate::utils::SdpMatrix2<N>;
231}
232
233#[cfg(not(feature = "simd-is-enabled"))]
234mod simd {
235 pub const SIMD_WIDTH: usize = 1;
237 pub const SIMD_LAST_INDEX: usize = 0;
239
240 #[cfg(feature = "f32")]
242 pub type SimdReal = f32;
243
244 #[cfg(feature = "f64")]
246 pub type SimdReal = f64;
247
248 pub type SimdBool = bool;
250}
251
252#[cfg(feature = "simd-is-enabled")]
253mod simd {
254 #[cfg(all(feature = "simd-nightly", feature = "f32"))]
255 pub use simba::simd::{f32x4 as SimdReal, mask32x4 as SimdBool};
256 #[cfg(all(feature = "simd-stable", feature = "f32"))]
257 pub use simba::simd::{WideBoolF32x4 as SimdBool, WideF32x4 as SimdReal};
258
259 #[cfg(all(feature = "simd-nightly", feature = "f64"))]
260 pub use simba::simd::{f64x4 as SimdReal, mask64x4 as SimdBool};
261 #[cfg(all(feature = "simd-stable", feature = "f64"))]
262 pub use simba::simd::{WideBoolF64x4 as SimdBool, WideF64x4 as SimdReal};
263
264 pub const SIMD_WIDTH: usize = 4;
266 pub const SIMD_LAST_INDEX: usize = 3;
268}