Skip to main content

Body

Struct Body 

Source
pub struct Body {
    pub name: String,
    pub inertia: SpatialInertia,
    pub parent: i32,
    pub joint_idx: usize,
    pub geometry: Option<Geometry>,
    pub collisions: Vec<GeomInstance>,
    pub visuals: Vec<GeomInstance>,
    pub material: Option<ContactMaterial>,
}
Expand description

A rigid body in the kinematic tree.

Fields§

§name: String

Name of the body (optional, for debugging).

§inertia: SpatialInertia

Spatial inertia in body-local frame.

§parent: i32

Index of the parent body (-1 for world/root).

§joint_idx: usize

Index of the joint connecting this body to its parent.

§geometry: Option<Geometry>

Primary collision geometry, centred on the body frame (if any).

This is the shape used by the contact pipeline. For sources that describe several offset shapes per body (URDF, MJCF) the full set lives in Body::collisions; geometry mirrors the first one whose origin is the identity, so existing single-shape consumers keep working.

§collisions: Vec<GeomInstance>

All collision shapes attached to this body, each with its own offset.

§visuals: Vec<GeomInstance>

Visual-only shapes attached to this body (not used for contact).

§material: Option<ContactMaterial>

This body’s own contact material, or None to use the scene default.

The material applies to every contact this body is part of — against the ground and against every other body — and the pair is resolved by ContactMaterial::combine. None means “whatever the scene is made of”, which is what keeps existing models unchanged: crate::Model::contact_materials fills those slots with the scene material and the assembled problem is bit-identical to the old vec![one; n_bodies].

Which body you attach it to is a physical decision, not a bookkeeping one. combine takes the maximum friction of the pair, so a grippy material grips everything the body touches. Putting grip tape’s mu = 1.5 on a skateboard deck also makes the deck’s underside grab the asphalt when the tail scrapes — measured, that braked a board from 0.6 to 0.39 m/s and killed the trick. Putting the same 1.5 on the shoes raises only the foot-on-deck contacts and leaves the deck-on- ground contact at wood’s 0.6. See the crate docs on ContactMaterial::combine.

§The ground has no material of its own

A contact against the ground plane or a heightfield uses the touching body’s material verbatim — there is no second material to combine with, so nothing is combined. That is easy to miss now that bodies differ from one another: setting a deck to wood’s 0.6 and passing asphalt’s 0.8 as the scene material gives a deck-on-ground friction of 0.6, not max(0.6, 0.8). The scene material is a default filler for bodies that carry none, not a property of the ground.

So the friction a body has against the ground is exactly the friction you wrote on that body, and a “road surface” is expressed by leaving the bodies that touch it on the scene material.

Implementations§

Source§

impl Body

Source

pub fn new( name: &str, inertia: SpatialInertia, parent: i32, joint_idx: usize, ) -> Self

Create a body with no attached geometry.

Source

pub fn with_material(self, material: ContactMaterial) -> Self

Attach a contact material to this body.

Read Body::material before choosing which body gets it: friction combines by max, so the material belongs on the part that should grip, not on the part it touches.

Trait Implementations§

Source§

impl Clone for Body

Source§

fn clone(&self) -> Body

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Body

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Body

§

impl RefUnwindSafe for Body

§

impl Send for Body

§

impl Sync for Body

§

impl Unpin for Body

§

impl UnsafeUnpin for Body

§

impl UnwindSafe for Body

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.