Skip to main content

box3d_rust/
lib.rs

1//! Pure Rust port of [Box3D](https://github.com/erincatto/box3d), Erin Catto's 3D physics
2//! engine for games.
3//!
4//! The port targets exact behavioral match with the C source pinned in the
5//! `box3d-cpp-reference/` submodule: same algorithms, same `f32` arithmetic, same edge
6//! cases, including Box3D's hand-rolled cross-platform-deterministic trigonometry.
7//!
8//! Enable the `double-precision` feature to mirror upstream `BOX3D_DOUBLE_PRECISION`
9//! (large-world mode). See the repository README for status and a quick-start.
10
11pub mod aabb;
12pub mod bitset;
13pub mod body;
14pub mod broad_phase;
15pub mod compound;
16pub mod constants;
17pub mod constraint_graph;
18pub mod contact;
19pub mod contact_solver;
20pub mod core;
21pub mod debug_draw;
22pub mod determinism;
23pub mod distance;
24pub mod dynamic_tree;
25pub mod events;
26pub mod geometry;
27pub mod height_field;
28pub mod hull;
29pub mod human;
30pub mod id;
31pub mod id_pool;
32pub mod island;
33pub mod joint;
34pub mod manifold;
35pub mod math_functions;
36pub mod mesh;
37pub mod mover;
38pub mod name_cache;
39pub mod recording;
40pub mod sensor;
41pub mod shape;
42pub mod solver;
43pub mod solver_set;
44pub mod table;
45pub mod types;
46pub mod world;
47
48pub use debug_draw::{
49    make_debug_color, CreateDebugShapeCallback, DebugDraw, DebugMaterial, DebugShape,
50    DestroyDebugShapeCallback, HexColor,
51};
52pub use id::{BodyId, ContactId, JointId, ShapeId, WorldId};
53pub use math_functions::{
54    Aabb, CosSin, Matrix3, Plane, Pos, Quat, SegmentDistanceResult, Transform, Triangle, Vec2,
55    Vec3, WorldTransform, MAT3_IDENTITY, MAT3_ZERO, PI, POS_ZERO, QUAT_IDENTITY,
56    TRANSFORM_IDENTITY, VEC3_AXIS_X, VEC3_AXIS_Y, VEC3_AXIS_Z, VEC3_ONE, VEC3_ZERO,
57    WORLD_TRANSFORM_IDENTITY,
58};
59pub use types::{
60    default_body_def, default_distance_joint_def, default_explosion_def, default_filter,
61    default_filter_joint_def, default_motor_joint_def, default_parallel_joint_def,
62    default_prismatic_joint_def, default_query_filter, default_revolute_joint_def,
63    default_shape_def, default_spherical_joint_def, default_weld_joint_def,
64    default_wheel_joint_def, default_world_def, BodyDef, BodyType, Capacity, Counters,
65    DistanceJointDef, ExplosionDef, Filter, FilterJointDef, JointDef, MotionLocks, MotorJointDef,
66    ParallelJointDef, PrismaticJointDef, QueryFilter, RayResult, RevoluteJointDef, ShapeDef,
67    SphericalJointDef, WeldJointDef, WheelJointDef, WorldCastOutput, WorldDef, BODY_TYPE_COUNT,
68};
69
70/// Crate version, exposed so demos and downstream tools can report the exact port build.
71pub const VERSION: &str = env!("CARGO_PKG_VERSION");
72
73#[cfg(test)]
74mod aabb_tests;
75
76#[cfg(test)]
77mod bitset_tests;
78
79#[cfg(test)]
80mod body_tests;
81
82#[cfg(test)]
83mod body_api_tests;
84
85#[cfg(test)]
86mod body_query_tests;
87
88#[cfg(test)]
89mod broad_phase_tests;
90
91#[cfg(test)]
92mod compound_tests;
93
94#[cfg(test)]
95mod contact_tests;
96
97#[cfg(test)]
98mod debug_draw_tests;
99
100#[cfg(test)]
101mod distance_tests;
102
103#[cfg(test)]
104mod dynamic_tree_tests;
105
106#[cfg(test)]
107mod geometry_tests;
108
109#[cfg(test)]
110mod height_field_tests;
111
112#[cfg(test)]
113mod hull_tests;
114
115#[cfg(test)]
116mod id_tests;
117
118#[cfg(test)]
119mod joint_tests;
120
121#[cfg(test)]
122mod manifold_tests;
123
124#[cfg(test)]
125mod math_functions_tests;
126
127#[cfg(test)]
128mod mesh_tests;
129
130#[cfg(test)]
131mod mover_tests;
132
133#[cfg(test)]
134mod shape_tests;
135
136#[cfg(test)]
137mod shape_api_tests;
138
139#[cfg(test)]
140mod table_tests;
141
142#[cfg(test)]
143mod world_tests;
144
145#[cfg(test)]
146mod world_api_tests;
147
148#[cfg(test)]
149mod large_world_tests;
150
151#[cfg(test)]
152mod determinism_tests;
153
154#[cfg(test)]
155mod recording_tests;
156
157#[cfg(test)]
158mod recording_replay_tests;
159
160#[cfg(test)]
161mod tests {
162    use super::*;
163
164    #[test]
165    fn version_matches_cargo_manifest() {
166        assert_eq!(VERSION, env!("CARGO_PKG_VERSION"));
167        assert!(!VERSION.is_empty());
168    }
169}