1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//!
//! # Official integration of Rapier to the Bevy game engine
//!
//! Rapier is a set of two Rust crates `rapier2d` and `rapier3d` for efficient cross-platform
//! physics simulation. It target application include video games, animation, robotics, etc.
//!
//! The `bevy_rapier` projects implements two other crates `bevy_rapier2d` and `bevy_rapier3d` which
//! defines physics plugins for the Bevy game engine.
//!
//! User documentation for `bevy_rapier` is on [the official Rapier site](https://rapier.rs/docs/).
//!

#![warn(missing_docs)]

#[macro_use]
#[cfg(feature = "serde-serialize")]
extern crate serde;

pub extern crate nalgebra as na;
#[cfg(feature = "dim2")]
pub extern crate rapier2d as rapier;
#[cfg(feature = "dim3")]
pub extern crate rapier3d as rapier;
pub use rapier::parry;

/// Type aliases to select the right vector/rotation types based
/// on the dimension used by the engine.
#[cfg(feature = "dim2")]
pub mod math {
    use bevy::math::Vec2;
    /// The real type (f32 or f64).
    pub type Real = rapier::math::Real;
    /// The vector type.
    pub type Vect = Vec2;
    /// The rotation type (in 2D this is an angle in radians).
    pub type Rot = Real;
}

/// Type aliases to select the right vector/rotation types based
/// on the dimension used by the engine.
#[cfg(feature = "dim3")]
pub mod math {
    use bevy::math::{Quat, Vec3};
    /// The real type (f32 or f64).
    pub type Real = rapier::math::Real;
    /// The vector type.
    pub type Vect = Vec3;
    /// The rotation type.
    pub type Rot = Quat;
}

/// Components related to physics dynamics (rigid-bodies, velocities, etc.)
pub mod dynamics;
/// Components related to physics geometry (colliders, collision-groups, etc.)
pub mod geometry;
/// Components and resources related to the physics simulation workflow (events, hooks, etc.)
pub mod pipeline;
/// The physics plugin and systems.
pub mod plugin;

/// The debug-renderer.
#[cfg(feature = "debug-render")]
pub mod render;
/// Miscellaneous helper functions.
pub mod utils;

/// Groups the most often used types.
pub mod prelude {
    pub use crate::dynamics::*;
    pub use crate::geometry::*;
    pub use crate::math::*;
    pub use crate::pipeline::*;
    pub use crate::plugin::*;
    #[cfg(feature = "debug-render")]
    pub use crate::render::*;
}