1#![no_std]
14#![deny(bare_trait_objects)]
15#![warn(missing_docs)]
16#![allow(clippy::too_many_arguments)]
17#![allow(clippy::needless_range_loop)] #![allow(clippy::module_inception)]
19#![cfg_attr(feature = "simd-nightly", feature(portable_simd))]
20
21#[cfg(feature = "std")]
22extern crate std;
23
24#[cfg(feature = "alloc")]
25extern crate alloc;
26
27#[cfg(all(feature = "dim2", feature = "f32"))]
28pub extern crate parry2d as parry;
29#[cfg(all(feature = "dim2", feature = "f64"))]
30pub extern crate parry2d_f64 as parry;
31#[cfg(all(feature = "dim3", feature = "f32"))]
32pub extern crate parry3d as parry;
33#[cfg(all(feature = "dim3", feature = "f64"))]
34pub extern crate parry3d_f64 as parry;
35
36#[cfg(feature = "alloc")]
38#[doc(hidden)]
39#[allow(unused_imports)]
40pub(crate) mod alloc_prelude {
41 pub use alloc::{boxed::Box, string::String, string::ToString, vec, vec::Vec};
42}
43
44#[cfg(not(target_arch = "spirv"))]
45pub extern crate nalgebra as na;
46#[cfg(feature = "serde-serialize")]
47#[macro_use]
48extern crate serde;
49extern crate num_traits as num;
50
51pub use parry::glamx;
52
53#[cfg(feature = "parallel")]
54pub use rayon;
55
56#[cfg(all(
57 feature = "simd-is-enabled",
58 not(feature = "simd-stable"),
59 not(feature = "simd-nightly")
60))]
61core::compile_error!(
62 "The `simd-is-enabled` feature should not be enabled explicitly. Please enable the `simd-stable` or the `simd-nightly` feature instead."
63);
64#[cfg(all(feature = "simd-is-enabled", feature = "enhanced-determinism"))]
65core::compile_error!(
66 "SIMD cannot be enabled when the `enhanced-determinism` feature is also enabled."
67);
68
69#[allow(unused_macros)]
70macro_rules! enable_flush_to_zero(
71 () => {
72 let _flush_to_zero = crate::utils::FlushToZeroDenormalsAreZeroFlags::flush_denormal_to_zero();
73 }
74);
75
76#[allow(unused_macros)]
77macro_rules! gather(
78 ($callback: expr) => {
79 {
80 #[inline(always)]
81 #[allow(dead_code)]
82 #[cfg(not(feature = "simd-is-enabled"))]
83 fn create_arr<T>(mut callback: impl FnMut(usize) -> T) -> T {
84 callback(0usize)
85 }
86
87 #[inline(always)]
88 #[allow(dead_code)]
89 #[cfg(feature = "simd-is-enabled")]
90 fn create_arr<T>(mut callback: impl FnMut(usize) -> T) -> [T; SIMD_WIDTH] {
91 [callback(0usize), callback(1usize), callback(2usize), callback(3usize)]
92 }
93
94
95 create_arr($callback)
96 }
97 }
98);
99
100#[allow(unused_macros)]
101macro_rules! array(
102 ($callback: expr) => {
103 {
104 #[inline(always)]
105 #[allow(dead_code)]
106 fn create_arr<T>(mut callback: impl FnMut(usize) -> T) -> [T; SIMD_WIDTH] {
107 #[cfg(not(feature = "simd-is-enabled"))]
108 return [callback(0usize)];
109 #[cfg(feature = "simd-is-enabled")]
110 return [callback(0usize), callback(1usize), callback(2usize), callback(3usize)];
111 }
112
113 create_arr($callback)
114 }
115 }
116);
117
118#[allow(unused_macros)]
119macro_rules! par_iter {
120 ($t: expr) => {{
121 #[cfg(not(feature = "parallel"))]
122 let it = $t.iter();
123
124 #[cfg(feature = "parallel")]
125 let it = $t.par_iter();
126 it
127 }};
128}
129
130#[allow(unused_macros)]
131macro_rules! par_iter_mut {
132 ($t: expr) => {{
133 #[cfg(not(feature = "parallel"))]
134 let it = $t.iter_mut();
135
136 #[cfg(feature = "parallel")]
137 let it = $t.par_iter_mut();
138 it
139 }};
140}
141
142#[allow(unused_macros)]
154macro_rules! try_ret {
155 ($val: expr) => {
156 try_ret!($val, ())
157 };
158 ($val: expr, $ret: expr) => {
159 if let Some(val) = $val {
160 val
161 } else {
162 return $ret;
163 }
164 };
165}
166
167#[allow(dead_code)]
178pub(crate) const INVALID_U32: u32 = u32::MAX;
179#[allow(dead_code)]
180pub(crate) const INVALID_USIZE: usize = INVALID_U32 as usize;
181
182pub const VERSION: &str = env!("CARGO_PKG_VERSION");
184
185pub mod control;
186pub mod counters;
187pub mod data;
188pub mod dynamics;
189pub mod geometry;
190pub mod pipeline;
191pub mod utils;
192
193pub mod math {
195 pub use parry::math::*;
196
197 pub use parry::glamx;
199
200 #[cfg(feature = "dim2")]
205 #[inline]
206 pub fn rotation_from_angle(angle: AngVector) -> Rotation {
207 Rotation::new(angle)
208 }
209
210 #[cfg(feature = "dim3")]
215 #[inline]
216 pub fn rotation_from_angle(angle: AngVector) -> Rotation {
217 Rotation::from_scaled_axis(angle)
218 }
219
220 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
226 pub type SimdVector<N> = na::Vector2<N>;
227 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
229 pub type SimdVector<N> = na::Vector3<N>;
230 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
232 pub type SimdAngVector<N> = N;
233 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
235 pub type SimdAngVector<N> = na::Vector3<N>;
236 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
238 pub type SimdPoint<N> = na::Point2<N>;
239 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
241 pub type SimdPoint<N> = na::Point3<N>;
242 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
244 pub type SimdPose<N> = na::Isometry2<N>;
245 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
247 pub type SimdPose<N> = na::Isometry3<N>;
248 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
250 pub type SimdRotation<N> = na::UnitComplex<N>;
251 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
253 pub type SimdRotation<N> = na::UnitQuaternion<N>;
254 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
256 pub type SimdAngularInertia<N> = N;
257 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
259 pub type SimdAngularInertia<N> = parry::utils::SdpMatrix3<N>;
260 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
262 pub type SimdMatrix<N> = na::Matrix2<N>;
263 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
265 pub type SimdMatrix<N> = na::Matrix3<N>;
266
267 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
270 pub type Dim = na::U2;
271 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
273 pub type Dim = na::U3;
274 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
276 pub type AngDim = na::U1;
277 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
279 pub type AngDim = na::U3;
280
281 #[cfg(feature = "alloc")]
283 pub type DVector = na::DVector<Real>;
284 #[cfg(feature = "alloc")]
286 pub type DMatrix = na::DMatrix<Real>;
287
288 #[cfg(feature = "dim2")]
295 pub const MAX_MANIFOLD_POINTS: usize = 2;
296
297 #[cfg(all(feature = "dim2", feature = "alloc"))]
299 pub type Jacobian<N> = na::Matrix3xX<N>;
300
301 #[cfg(all(feature = "dim2", feature = "alloc"))]
303 pub type JacobianView<'a, N> = na::MatrixView3xX<'a, N>;
304
305 #[cfg(all(feature = "dim2", feature = "alloc"))]
307 pub type JacobianViewMut<'a, N> = na::MatrixViewMut3xX<'a, N>;
308
309 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
311 pub type TangentImpulse<N> = na::Vector1<N>;
312
313 #[cfg(feature = "dim2")]
315 pub const SPATIAL_DIM: usize = 3;
316
317 #[cfg(feature = "dim2")]
319 pub const ANG_DIM: usize = 1;
320
321 #[cfg(feature = "dim3")]
328 pub const MAX_MANIFOLD_POINTS: usize = 4;
329
330 #[cfg(all(feature = "dim3", feature = "alloc"))]
332 pub type Jacobian<N> = na::Matrix6xX<N>;
333
334 #[cfg(all(feature = "dim3", feature = "alloc"))]
336 pub type JacobianView<'a, N> = na::MatrixView6xX<'a, N>;
337
338 #[cfg(all(feature = "dim3", feature = "alloc"))]
340 pub type JacobianViewMut<'a, N> = na::MatrixViewMut6xX<'a, N>;
341
342 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
344 pub type TangentImpulse<N> = na::Vector2<N>;
345
346 #[cfg(feature = "dim3")]
348 pub const SPATIAL_DIM: usize = 6;
349
350 #[cfg(feature = "dim3")]
352 pub const ANG_DIM: usize = 3;
353}
354
355pub mod prelude {
357 #[cfg(feature = "alloc")]
358 pub use crate::dynamics::*;
359 #[cfg(feature = "alloc")]
360 pub use crate::geometry::*;
361 pub use crate::math::*;
362 #[cfg(feature = "alloc")]
363 pub use crate::pipeline::*;
364 #[cfg(not(target_arch = "spirv"))]
365 pub use na::{point, vector};
366 #[cfg(not(target_arch = "spirv"))]
367 pub extern crate nalgebra;
368}