Skip to main content

phyz_model/
body.rs

1//! Rigid body definition.
2
3use phyz_math::SpatialInertia;
4
5/// A rigid body in the kinematic tree.
6#[derive(Debug, Clone)]
7pub struct Body {
8    /// Name of the body (optional, for debugging).
9    pub name: String,
10    /// Spatial inertia in body-local frame.
11    pub inertia: SpatialInertia,
12    /// Index of the parent body (-1 for world/root).
13    pub parent: i32,
14    /// Index of the joint connecting this body to its parent.
15    pub joint_idx: usize,
16    /// Collision geometry (if any).
17    pub geometry: Option<Geometry>,
18}
19
20/// Collision geometry types (re-exported from phyz-collision for convenience).
21#[derive(Debug, Clone)]
22pub enum Geometry {
23    Sphere {
24        radius: f64,
25    },
26    Capsule {
27        radius: f64,
28        length: f64,
29    },
30    Box {
31        half_extents: phyz_math::Vec3,
32    },
33    Cylinder {
34        radius: f64,
35        height: f64,
36    },
37    Mesh {
38        vertices: Vec<phyz_math::Vec3>,
39        faces: Vec<[usize; 3]>,
40    },
41    Plane {
42        normal: phyz_math::Vec3,
43    },
44}