1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::mass_properties::MassProperties;
use crate::math::{Isometry, Real};
use crate::shape::SharedShape;

impl MassProperties {
    /// Computes the mass properties of a compound shape.
    pub fn from_compound(density: Real, shapes: &[(Isometry<Real>, SharedShape)]) -> Self {
        shapes
            .iter()
            .map(|s| s.1.mass_properties(density).transform_by(&s.0))
            .sum()
    }
}