Skip to main content

box3d_rust/human/
mod.rs

1//! Human ragdoll builder from `shared/human.c` / `shared/human.h`.
2//!
3//! Capsule bones + spherical/revolute joint tree used by the determinism scene
4//! and (later) joint sample demos.
5//!
6//! SPDX-FileCopyrightText: 2026 Erin Catto
7//! SPDX-License-Identifier: MIT
8
9mod api;
10mod create;
11mod random;
12mod types;
13
14pub use api::*;
15pub use create::create_human;
16pub use types::*;
17
18#[cfg(test)]
19mod tests {
20    use super::*;
21    use crate::math_functions::POS_ZERO;
22    use crate::types::default_world_def;
23    use crate::world::World;
24
25    #[test]
26    fn create_and_destroy_human() {
27        let mut world = World::new(&default_world_def());
28        let mut human = Human::default();
29        create_human(&mut human, &mut world, POS_ZERO, 5.0, 1.0, 0.7, 1, 0, false);
30        assert!(human.is_spawned);
31        assert!(!human.bones[BoneId::Pelvis as usize].body_id.is_null());
32        assert!(!human.bones[BoneId::Head as usize].joint_id.is_null());
33        assert_eq!(human.filter_joint_count, 1);
34        destroy_human(&mut human, &mut world);
35        assert!(!human.is_spawned);
36    }
37}