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
36macro_rules! array(
37 ($callback: expr; SIMD_WIDTH) => {
38 {
39 #[inline(always)]
40 #[allow(dead_code)]
41 fn create_arr<T>(mut callback: impl FnMut(usize) -> T) -> [T; SIMD_WIDTH] {
42 [callback(0usize), callback(1usize), callback(2usize), callback(3usize)]
43 }
44
45 create_arr($callback)
46 }
47 }
48);
49
50#[cfg(feature = "std")]
51extern crate std;
52
53#[cfg(feature = "alloc")]
54#[cfg_attr(test, macro_use)]
55extern crate alloc;
56
57#[cfg(feature = "serde")]
58#[macro_use]
59extern crate serde;
60#[macro_use]
61extern crate approx;
62extern crate num_traits as num;
63
64pub extern crate either;
65pub extern crate nalgebra as na;
66pub extern crate simba;
67
68pub mod bounding_volume;
69pub mod mass_properties;
70pub mod partitioning;
71pub mod query;
72pub mod shape;
73#[cfg(feature = "alloc")]
74pub mod transformation;
75pub mod utils;
76
77mod real {
78 #[cfg(feature = "f64")]
80 pub use f64 as Real;
81
82 #[cfg(feature = "f32")]
84 pub use f32 as Real;
85}
86
87#[cfg(feature = "dim3")]
89pub mod math {
90 pub use super::real::*;
91 pub use super::simd::*;
92 use na::{
93 Isometry3, Matrix3, Point3, Translation3, UnitQuaternion, UnitVector3, Vector3, Vector6,
94 U3, U6,
95 };
96
97 pub const DEFAULT_EPSILON: Real = Real::EPSILON;
99
100 pub const DIM: usize = 3;
102
103 pub const TWO_DIM: usize = DIM * 2;
105
106 pub type Dim = U3;
108
109 pub type SpatialDim = U6;
111
112 pub type AngDim = U3;
114
115 pub type Point<N> = Point3<N>;
117
118 pub type AngVector<N> = Vector3<N>;
120
121 pub type Vector<N> = Vector3<N>;
123
124 pub type UnitVector<N> = UnitVector3<N>;
126
127 pub type Matrix<N> = Matrix3<N>;
129
130 pub type SpatialVector<N> = Vector6<N>;
132
133 pub type Orientation<N> = Vector3<N>;
135
136 pub type Isometry<N> = Isometry3<N>;
138
139 pub type Rotation<N> = UnitQuaternion<N>;
141
142 pub type Translation<N> = Translation3<N>;
144
145 pub type AngularInertia<N> = crate::utils::SdpMatrix3<N>;
147
148 pub type PrincipalAngularInertia<N> = Vector3<N>;
150
151 pub type CrossMatrix<N> = Matrix3<N>;
153
154 pub type SpacialVector<N> = Vector6<N>;
156
157 pub type SdpMatrix<N> = crate::utils::SdpMatrix3<N>;
159}
160
161#[cfg(feature = "dim2")]
163pub mod math {
164 pub use super::real::*;
165 pub use super::simd::*;
166 use na::{
167 Isometry2, Matrix2, Point2, Translation2, UnitComplex, UnitVector2, Vector1, Vector2,
168 Vector3, U1, U2,
169 };
170
171 pub const DEFAULT_EPSILON: Real = Real::EPSILON;
173
174 pub const DIM: usize = 2;
176
177 pub const TWO_DIM: usize = DIM * 2;
179
180 pub type Dim = U2;
182
183 pub type AngDim = U1;
185
186 pub type Point<N> = Point2<N>;
188
189 pub type AngVector<N> = N;
191
192 pub type Vector<N> = Vector2<N>;
194
195 pub type UnitVector<N> = UnitVector2<N>;
197
198 pub type Matrix<N> = Matrix2<N>;
200
201 pub type Orientation<N> = Vector1<N>;
203
204 pub type Isometry<N> = Isometry2<N>;
206
207 pub type Rotation<N> = UnitComplex<N>;
209
210 pub type Translation<N> = Translation2<N>;
212
213 pub type AngularInertia<N> = N;
215
216 pub type PrincipalAngularInertia<N> = N;
218
219 pub type CrossMatrix<N> = Vector2<N>;
221
222 pub type SpacialVector<N> = Vector3<N>;
224
225 pub type SdpMatrix<N> = crate::utils::SdpMatrix2<N>;
227}
228
229#[cfg(not(feature = "simd-is-enabled"))]
230mod simd {
231 use simba::simd::AutoBoolx4;
232 pub const SIMD_WIDTH: usize = 4;
234 pub const SIMD_LAST_INDEX: usize = 3;
236
237 #[cfg(feature = "f32")]
239 pub type SimdReal = simba::simd::AutoF32x4;
240
241 #[cfg(feature = "f64")]
243 pub type SimdReal = simba::simd::AutoF64x4;
244
245 pub type SimdBool = AutoBoolx4;
247}
248
249#[cfg(feature = "simd-is-enabled")]
250mod simd {
251 #[cfg(all(feature = "simd-nightly", feature = "f32"))]
252 pub use simba::simd::{f32x4 as SimdReal, mask32x4 as SimdBool};
253 #[cfg(all(feature = "simd-stable", feature = "f32"))]
254 pub use simba::simd::{WideBoolF32x4 as SimdBool, WideF32x4 as SimdReal};
255
256 #[cfg(all(feature = "simd-nightly", feature = "f64"))]
257 pub use simba::simd::{f64x4 as SimdReal, mask64x4 as SimdBool};
258 #[cfg(all(feature = "simd-stable", feature = "f64"))]
259 pub use simba::simd::{WideBoolF64x4 as SimdBool, WideF64x4 as SimdReal};
260
261 pub const SIMD_WIDTH: usize = 4;
263 pub const SIMD_LAST_INDEX: usize = 3;
265}