#[non_exhaustive]pub enum Shape {
Box {
half_extents: Vec3,
},
Sphere {
radius: f32,
},
}Expand description
A convex collision shape. 凸碰撞形状。
Cylinder, cone, and convex hull are planned but not implemented yet; see
docs/physics-spec.md §4.
圆柱、圆锥与凸包已规划但尚未实现;见 docs/physics-spec.md §4。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Box
An axis-aligned box described by its half extents. 由半长描述的轴对齐盒。
Sphere
A sphere described by its radius. 由半径描述的球。
Implementations§
Source§impl Shape
impl Shape
Sourcepub fn cuboid(half_extents: Vec3) -> Self
pub fn cuboid(half_extents: Vec3) -> Self
An axis-aligned box with the given half extents. 给定半长的轴对齐盒。
Half extents are clamped to be non-negative, so a negative input yields a degenerate (zero-volume) box rather than an inverted one. 半长被钳制为非负,因此负输入得到退化的(零体积)盒,而不是内外翻转的盒。
Sourcepub fn sphere(radius: f32) -> Self
pub fn sphere(radius: f32) -> Self
A sphere with the given radius, clamped to be non-negative. 给定半径的球;半径被钳制为非负。
Sourcepub fn volume(&self) -> f32
pub fn volume(&self) -> f32
The shape’s volume, used to sanity-check mass input. 形状的体积,用于校验质量输入。
Sourcepub fn local_inertia(&self, mass: f32) -> Vec3
pub fn local_inertia(&self, mass: f32) -> Vec3
The local inertia tensor’s diagonal for a given total mass. 给定总质量时,局部惯量张量的对角元。
Sourcepub fn mass_properties(&self, mass: f32) -> MassProperties
pub fn mass_properties(&self, mass: f32) -> MassProperties
Inverse mass properties for a given total mass. 给定总质量时的逆质量属性。
A non-finite or non-positive mass yields MassProperties::IMMOVABLE. A
component of the inertia tensor that is zero (a degenerate shape) yields a
zero inverse on that axis, so the Body simply never resists that rotation
instead of producing inf.
非有限或非正的 mass 返回 MassProperties::IMMOVABLE。惯量张量的某个分量为零
(退化形状)时,该轴的逆值为零,于是 Body 只是不抵抗该轴旋转,而不会产生 inf。