#[repr(C)]pub struct b2BodyDef {Show 18 fields
pub type_: b2BodyType,
pub position: b2Vec2,
pub rotation: b2Rot,
pub linearVelocity: b2Vec2,
pub angularVelocity: f32,
pub linearDamping: f32,
pub angularDamping: f32,
pub gravityScale: f32,
pub sleepThreshold: f32,
pub name: *const c_char,
pub userData: *mut c_void,
pub motionLocks: b2MotionLocks,
pub enableSleep: bool,
pub isAwake: bool,
pub isBullet: bool,
pub isEnabled: bool,
pub allowFastRotation: bool,
pub internalValue: c_int,
}Expand description
A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction. Body definitions are temporary objects used to bundle creation parameters. Must be initialized using b2DefaultBodyDef(). @ingroup body
Fields§
§type_: b2BodyTypeThe body type: static, kinematic, or dynamic.
position: b2Vec2The initial world position of the body. Bodies should be created with the desired position. @note Creating bodies at the origin and then moving them nearly doubles the cost of body creation, especially if the body is moved after shapes have been added.
rotation: b2RotThe initial world rotation of the body. Use b2MakeRot() if you have an angle.
linearVelocity: b2Vec2The initial linear velocity of the body’s origin. Usually in meters per second.
angularVelocity: f32The initial angular velocity of the body. Radians per second.
linearDamping: f32Linear damping is used to reduce the linear velocity. The damping parameter can be larger than 1 but the damping effect becomes sensitive to the time step when the damping parameter is large. Generally linear damping is undesirable because it makes objects move slowly as if they are floating.
angularDamping: f32Angular damping is used to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. Angular damping can be use slow down rotating bodies.
gravityScale: f32Scale the gravity applied to this body. Non-dimensional.
sleepThreshold: f32Sleep speed threshold, default is 0.05 meters per second
name: *const c_charOptional body name for debugging. Up to 31 characters (excluding null termination)
userData: *mut c_voidUse this to store application specific body data.
motionLocks: b2MotionLocksMotions locks to restrict linear and angular movement. Caution: may lead to softer constraints along the locked direction
enableSleep: boolSet this flag to false if this body should never fall asleep.
isAwake: boolIs this body initially awake or sleeping?
isBullet: boolTreat this body as a high speed object that performs continuous collision detection against dynamic and kinematic bodies, but not other bullet bodies. @warning Bullets should be used sparingly. They are not a solution for general dynamic-versus-dynamic continuous collision. They do not guarantee accurate collision if both bodies are fast moving because the bullet does a continuous check after all non-bullet bodies have moved. You could get unlucky and have the bullet body end a time step very close to a non-bullet body and the non-bullet body then moves over the bullet body. In continuous collision, initial overlap is ignored to avoid freezing bodies in place. I do not recommend using them for game projectiles if precise collision timing is needed. Instead consider using a ray or shape cast. You can use a marching ray or shape cast for projectile that moves over time. If you want a fast moving projectile to collide with a fast moving target, you need to consider the relative movement in your ray or shape cast. This is out of the scope of Box2D. So what are good use cases for bullets? Pinball games or games with dynamic containers that hold other objects. It should be a use case where it doesn’t break the game if there is a collision missed, but the having them captured improves the quality of the game.
isEnabled: boolUsed to disable a body. A disabled body does not move or collide.
allowFastRotation: boolThis allows this body to bypass rotational speed limits. Should only be used for circular objects, like wheels.
internalValue: c_intUsed internally to detect a valid definition. DO NOT SET.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for b2BodyDef
impl RefUnwindSafe for b2BodyDef
impl !Send for b2BodyDef
impl !Sync for b2BodyDef
impl Unpin for b2BodyDef
impl UnwindSafe for b2BodyDef
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)