#[non_exhaustive]pub struct BodyDesc {
pub shape: Shape,
pub motion: MotionType,
pub mass: f32,
pub position: Vec3,
pub orientation: Quat,
pub linear_velocity: Vec3,
pub angular_velocity: Vec3,
pub friction: f32,
pub restitution: f32,
pub linear_damping: f32,
pub gravity_scale: f32,
pub angular_damping: f32,
}Expand description
Construction parameters for a Body. Body 的构造参数。
Mass is the input and the inertia tensor is derived from the Shape, so the two
can never disagree. See docs/physics-spec.md §3.
输入的是质量,惯量张量由 Shape 推导,因此二者永不可能不一致。见
docs/physics-spec.md §3。
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.shape: ShapeThe Body’s collision shape. Body 的碰撞形状。
motion: MotionTypeHow the Body’s motion is produced. Body 的运动如何产生。
mass: f32Mass in kilograms. Ignored when motion is not MotionType::Dynamic.
质量(千克)。当 motion 不是 MotionType::Dynamic 时忽略。
position: Vec3Initial position. 初始位置。
orientation: QuatInitial orientation. Normalized on insertion. 初始朝向。插入时会被归一化。
linear_velocity: Vec3Initial linear velocity. 初始线速度。
angular_velocity: Vec3Initial angular velocity. 初始角速度。
friction: f32Coulomb friction coefficient. 库仑摩擦系数。
restitution: f32Bounciness, from 0 (no bounce) upward. 弹性,0 表示不反弹。
linear_damping: f32Velocity decay per second applied to linear motion. 每秒施加于线运动的衰减。
gravity_scale: f32How much of the World’s gravity reaches this Body. See
BodyDesc::with_gravity_scale.
World 的重力有多少作用于此 Body。见 BodyDesc::with_gravity_scale。
angular_damping: f32Velocity decay per second applied to angular motion. 每秒施加于角运动的衰减。
Implementations§
Source§impl BodyDesc
impl BodyDesc
Sourcepub fn new(shape: Shape, motion: MotionType) -> Self
pub fn new(shape: Shape, motion: MotionType) -> Self
A Body in the given motion mode, with the given shape. 给定运动模式与形状的 Body。
Sourcepub fn dynamic(shape: Shape, mass: f32) -> Self
pub fn dynamic(shape: Shape, mass: f32) -> Self
A Dynamic Body of the given shape and mass. A non-positive or non-finite mass yields a Body nothing can accelerate. 给定形状与质量的 Dynamic Body。非正或非有限的质量得到无法被加速的 Body。
Sourcepub fn stationary(shape: Shape) -> Self
pub fn stationary(shape: Shape) -> Self
A Static Body: it never moves. Static Body:永不移动。
Sourcepub fn kinematic(shape: Shape) -> Self
pub fn kinematic(shape: Shape) -> Self
A Kinematic Body, moved by whatever velocity the app sets on it. Kinematic Body,由应用设定的速度驱动。
Sourcepub fn with_velocity(self, velocity: Vec3) -> Self
pub fn with_velocity(self, velocity: Vec3) -> Self
Set the initial linear velocity. 设置初始线速度。
Sourcepub fn with_angular_velocity(self, angular_velocity: Vec3) -> Self
pub fn with_angular_velocity(self, angular_velocity: Vec3) -> Self
Set the initial angular velocity. 设置初始角速度。
Sourcepub fn with_friction(self, friction: f32) -> Self
pub fn with_friction(self, friction: f32) -> Self
Set the friction coefficient. 设置摩擦系数。
Sourcepub fn with_restitution(self, restitution: f32) -> Self
pub fn with_restitution(self, restitution: f32) -> Self
Set the restitution. 设置弹性。
Sourcepub fn with_gravity_scale(self, scale: f32) -> Self
pub fn with_gravity_scale(self, scale: f32) -> Self
Scale the World’s gravity for this Body. 按比例缩放作用于此 Body 的 World 重力。
0.0 means gravity never touches it, which is what a caller wants when
something else already owns the Body’s motion — a flight model, or anything
kinematic-in-spirit that still needs contacts and friction. 1.0 is the
default and 2.0 falls twice as fast.
0.0 表示重力永不作用于它,这正是当别的东西已经拥有该 Body 的运动时想要的——例如
飞行模型,或任何在精神上近似运动学、却仍需要接触与摩擦的东西。默认为 1.0,2.0
则以两倍速度下坠。
Negative or non-finite values are clamped to zero. 负值或非有限值被钳制为零。
Sourcepub fn with_damping(self, linear: f32, angular: f32) -> Self
pub fn with_damping(self, linear: f32, angular: f32) -> Self
Damping applied to linear and angular velocity. 施加于线速度与角速度的阻尼。