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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! The types most programs use, for `use oxijolt::prelude::*`.
//!
//! Without another prelude, import the math types from [`math`] next to it:
//!
//! ```
//! use oxijolt::prelude::math::*;
//! use oxijolt::prelude::*;
//!
//! # fn main() -> oxijolt::error::Result<()> {
//! let mut world = PhysicsWorld::new(WorldSettings::default())?;
//! let ball = world.create_body(
//! &Shape::new_sphere(0.5)?,
//! &BodySettings::new_dynamic().position(RVec3::new(0.0, 2.0, 0.0)),
//! )?;
//! assert!(world.step(1.0 / 60.0)?.is_complete());
//! assert!(world.body(ball)?.position().y < 2.0);
//! # Ok(())
//! # }
//! ```
//!
//! The prelude names no math type and no `Result`, so it can be glob-imported next to
//! `bevy::prelude::*`: `Vec3`, `Quat` and `Result` stay Bevy's. With the `glam032` feature,
//! `.into()` converts poses to Bevy's types; `?` in a system that returns Bevy's `Result`
//! converts any oxijolt error.
//!
//! ```ignore
//! use bevy::prelude::*;
//! use oxijolt::prelude::*;
//!
//! #[derive(Resource)]
//! struct Physics(PhysicsWorld);
//!
//! #[derive(Resource, Default)]
//! struct BodyEntities(std::collections::HashMap<BodyId, Entity>);
//!
//! fn sync_transforms(
//! physics: Res<Physics>,
//! bodies: Res<BodyEntities>,
//! mut transforms: Query<&mut Transform>,
//! ) {
//! for pose in physics.0.active_body_poses() {
//! let entity = bodies.0.get(&pose.id);
//! if let Some(mut transform) = entity.and_then(|&e| transforms.get_mut(e).ok()) {
//! transform.translation = pose.position.into();
//! transform.rotation = pose.rotation.into();
//! }
//! }
//! }
//!
//! fn step(mut physics: ResMut<Physics>, time: Res<Time<Fixed>>) -> Result {
//! let report = physics.0.step(time.delta_secs())?;
//! assert!(report.is_complete());
//! Ok(())
//! }
//! ```
//!
//! `pose.position.into()` gives a `glam::Vec3` in single precision; with `double-precision` it
//! gives a `glam::DVec3`.
//!
//! `active_body_poses` returns the bodies awake when it is called; a body that fell asleep at
//! the end of the step is not among them. [`PhysicsWorld::active_body_poses`] says how a game
//! syncs such bodies.
//!
//! [`Error`](crate::error::Error) and [`Result`](crate::error::Result) are written by path
//! (`oxijolt::error::Result`). The crate root, `use oxijolt::*`, brings in everything else, the
//! math types included.
pub use crateMutableCompound;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
pub use crate::;
/// The math types: [`Vec3`](crate::Vec3), [`RVec3`](crate::RVec3), [`Quat`](crate::Quat) and
/// [`Real`](crate::Real).