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(all(feature = "simd8", feature = "enhanced-determinism"))]
20core::compile_error!(
21 "8-lanes SIMD cannot be enabled when the `enhanced-determinism` feature is also enabled because it breaks cross-platform determinism."
22);
23
24#[cfg(feature = "std")]
25extern crate std;
26
27#[cfg(feature = "alloc")]
28extern crate alloc;
29
30#[cfg(all(feature = "dim2", feature = "f32"))]
31pub extern crate parry2d as parry;
32#[cfg(all(feature = "dim2", feature = "f64"))]
33pub extern crate parry2d_f64 as parry;
34#[cfg(all(feature = "dim3", feature = "f32"))]
35pub extern crate parry3d as parry;
36#[cfg(all(feature = "dim3", feature = "f64"))]
37pub extern crate parry3d_f64 as parry;
38
39#[cfg(feature = "alloc")]
41#[doc(hidden)]
42#[allow(unused_imports)]
43pub(crate) mod alloc_prelude {
44 pub use alloc::{boxed::Box, string::String, string::ToString, vec, vec::Vec};
45}
46
47#[cfg(not(target_arch = "spirv"))]
48pub extern crate nalgebra as na;
49#[cfg(feature = "serde-serialize")]
50#[macro_use]
51extern crate serde;
52extern crate num_traits as num;
53
54pub use parry::glamx;
55
56#[cfg(all(feature = "std", feature = "parallel"))]
57pub use rayon;
58
59#[allow(unused_macros)]
60macro_rules! gather(
61 ($callback: expr) => { array!($callback) }
62);
63
64#[allow(unused_macros)]
65macro_rules! array(
66 ($callback: expr) => {
67 {
68 #[inline(always)]
69 #[allow(dead_code)]
70 fn create_arr<T>(callback: impl FnMut(usize) -> T) -> [T; SIMD_WIDTH] {
71 core::array::from_fn(callback)
74 }
75
76 create_arr($callback)
77 }
78 }
79);
80
81#[allow(unused_macros)]
82macro_rules! par_iter {
83 ($t: expr) => {{
84 #[cfg(not(feature = "parallel"))]
85 let it = $t.iter();
86
87 #[cfg(feature = "parallel")]
88 let it = $t.par_iter();
89 it
90 }};
91}
92
93#[allow(unused_macros)]
94macro_rules! par_iter_mut {
95 ($t: expr) => {{
96 #[cfg(not(feature = "parallel"))]
97 let it = $t.iter_mut();
98
99 #[cfg(feature = "parallel")]
100 let it = $t.par_iter_mut();
101 it
102 }};
103}
104
105#[allow(unused_macros)]
117macro_rules! try_ret {
118 ($val: expr) => {
119 try_ret!($val, ())
120 };
121 ($val: expr, $ret: expr) => {
122 if let Some(val) = $val {
123 val
124 } else {
125 return $ret;
126 }
127 };
128}
129
130#[allow(dead_code)]
141pub(crate) const INVALID_U32: u32 = u32::MAX;
142#[allow(dead_code)]
143pub(crate) const INVALID_USIZE: usize = INVALID_U32 as usize;
144
145pub const VERSION: &str = env!("CARGO_PKG_VERSION");
147
148pub mod control;
149pub mod counters;
150pub mod data;
151pub mod dynamics;
152pub mod geometry;
153pub mod pipeline;
154pub mod utils;
155
156pub mod math {
158 pub use parry::math::*;
159
160 pub use parry::glamx;
162
163 #[cfg(feature = "dim2")]
168 #[inline]
169 pub fn rotation_from_angle(angle: AngVector) -> Rotation {
170 Rotation::new(angle)
171 }
172
173 #[cfg(feature = "dim3")]
178 #[inline]
179 pub fn rotation_from_angle(angle: AngVector) -> Rotation {
180 Rotation::from_scaled_axis(angle)
181 }
182
183 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
189 pub type SimdVector<N> = na::Vector2<N>;
190 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
192 pub type SimdVector<N> = na::Vector3<N>;
193 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
195 pub type SimdAngVector<N> = N;
196 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
198 pub type SimdAngVector<N> = na::Vector3<N>;
199 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
201 pub type SimdPoint<N> = na::Point2<N>;
202 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
204 pub type SimdPoint<N> = na::Point3<N>;
205 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
207 pub type SimdPose<N> = na::Isometry2<N>;
208 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
210 pub type SimdPose<N> = na::Isometry3<N>;
211 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
213 pub type SimdRotation<N> = na::UnitComplex<N>;
214 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
216 pub type SimdRotation<N> = na::UnitQuaternion<N>;
217 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
219 pub type SimdAngularInertia<N> = N;
220 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
222 pub type SimdAngularInertia<N> = parry::utils::SdpMatrix3<N>;
223 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
225 pub type SimdMatrix<N> = na::Matrix2<N>;
226 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
228 pub type SimdMatrix<N> = na::Matrix3<N>;
229
230 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
233 pub type Dim = na::U2;
234 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
236 pub type Dim = na::U3;
237 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
239 pub type AngDim = na::U1;
240 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
242 pub type AngDim = na::U3;
243
244 #[cfg(feature = "alloc")]
246 pub type DVector = na::DVector<Real>;
247 #[cfg(feature = "alloc")]
249 pub type DMatrix = na::DMatrix<Real>;
250
251 #[cfg(feature = "dim2")]
258 pub const MAX_MANIFOLD_POINTS: usize = 2;
259
260 #[cfg(all(feature = "dim2", feature = "alloc"))]
262 pub type Jacobian<N> = na::Matrix3xX<N>;
263
264 #[cfg(all(feature = "dim2", feature = "alloc"))]
266 pub type JacobianView<'a, N> = na::MatrixView3xX<'a, N>;
267
268 #[cfg(all(feature = "dim2", feature = "alloc"))]
270 pub type JacobianViewMut<'a, N> = na::MatrixViewMut3xX<'a, N>;
271
272 #[cfg(all(feature = "dim2", not(target_arch = "spirv")))]
274 pub type TangentImpulse<N> = na::Vector1<N>;
275
276 #[cfg(feature = "dim2")]
278 pub const SPATIAL_DIM: usize = 3;
279
280 #[cfg(feature = "dim2")]
282 pub const ANG_DIM: usize = 1;
283
284 #[cfg(feature = "dim3")]
291 pub const MAX_MANIFOLD_POINTS: usize = 4;
292
293 #[cfg(all(feature = "dim3", feature = "alloc"))]
295 pub type Jacobian<N> = na::Matrix6xX<N>;
296
297 #[cfg(all(feature = "dim3", feature = "alloc"))]
299 pub type JacobianView<'a, N> = na::MatrixView6xX<'a, N>;
300
301 #[cfg(all(feature = "dim3", feature = "alloc"))]
303 pub type JacobianViewMut<'a, N> = na::MatrixViewMut6xX<'a, N>;
304
305 #[cfg(all(feature = "dim3", not(target_arch = "spirv")))]
307 pub type TangentImpulse<N> = na::Vector2<N>;
308
309 #[cfg(feature = "dim3")]
311 pub const SPATIAL_DIM: usize = 6;
312
313 #[cfg(feature = "dim3")]
315 pub const ANG_DIM: usize = 3;
316}
317
318pub mod prelude {
333 #[cfg(feature = "alloc")]
334 pub use crate::dynamics::*;
335 #[cfg(feature = "alloc")]
336 pub use crate::geometry::*;
337 pub use crate::math::*;
338 #[cfg(feature = "alloc")]
339 pub use crate::pipeline::*;
340 #[cfg(not(target_arch = "spirv"))]
341 pub use na::{point, vector};
342 #[cfg(not(target_arch = "spirv"))]
343 pub extern crate nalgebra;
344}