Struct libliquidfun_sys::box2d::ffi::b2Body
source · #[repr(C, align(8))]pub struct b2Body { /* private fields */ }Expand description
A rigid body. These are created via b2World::CreateBody.
Implementations§
source§impl b2Body
impl b2Body
sourcepub fn GetTransform(self: &b2Body) -> &b2Transform
pub fn GetTransform(self: &b2Body) -> &b2Transform
Get the body transform for the body’s origin. @return the world transform of the body’s origin.
sourcepub fn GetAngle(self: &b2Body) -> f32
pub fn GetAngle(self: &b2Body) -> f32
Get the angle in radians. @return the current world rotation angle in radians.
sourcepub fn GetType(self: &b2Body) -> b2BodyType
pub fn GetType(self: &b2Body) -> b2BodyType
Get the type of this body.
sourcepub fn GetNext(self: Pin<&mut b2Body>) -> *mut b2Body
pub fn GetNext(self: Pin<&mut b2Body>) -> *mut b2Body
Get the next body in the world’s body list.
sourcepub fn GetUserData<'a>(self: Pin<&'a mut b2Body>) -> Pin<&'a mut b2BodyUserData>
pub fn GetUserData<'a>(self: Pin<&'a mut b2Body>) -> Pin<&'a mut b2BodyUserData>
Get the user data pointer that was provided in the body definition.
source§impl b2Body
impl b2Body
sourcepub unsafe fn CreateFixture(
self: Pin<&mut Self>,
def: *const b2FixtureDef
) -> *mut b2Fixture
pub unsafe fn CreateFixture( self: Pin<&mut Self>, def: *const b2FixtureDef ) -> *mut b2Fixture
Creates a fixture and attach it to this body. Use this function if you need to set some fixture parameters, like friction. Otherwise you can create the fixture directly from a shape. If the density is non-zero, this function automatically updates the mass of the body. Contacts are not created until the next time step. @param def the fixture definition. @warning This function is locked during callbacks.
source§impl b2Body
impl b2Body
sourcepub unsafe fn CreateFixture1(
self: Pin<&mut Self>,
shape: *const b2Shape,
density: f32
) -> *mut b2Fixture
pub unsafe fn CreateFixture1( self: Pin<&mut Self>, shape: *const b2Shape, density: f32 ) -> *mut b2Fixture
Creates a fixture from a shape and attach it to this body. This is a convenience function. Use b2FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. If the density is non-zero, this function automatically updates the mass of the body. @param shape the shape to be cloned. @param density the shape density (set to zero for static bodies). @warning This function is locked during callbacks.
source§impl b2Body
impl b2Body
sourcepub unsafe fn DestroyFixture(self: Pin<&mut Self>, fixture: *mut b2Fixture)
pub unsafe fn DestroyFixture(self: Pin<&mut Self>, fixture: *mut b2Fixture)
Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly destroyed when the body is destroyed. @param fixture the fixture to be removed. @warning This function is locked during callbacks.
source§impl b2Body
impl b2Body
sourcepub fn SetTransform(self: Pin<&mut Self>, position: &b2Vec2, angle: f32)
pub fn SetTransform(self: Pin<&mut Self>, position: &b2Vec2, angle: f32)
Set the position of the body’s origin and rotation. Manipulating a body’s transform may cause non-physical behavior. Note: contacts are updated on the next call to b2World::Step. @param position the world position of the body’s local origin. @param angle the world rotation in radians.
source§impl<'a> b2Body
impl<'a> b2Body
sourcepub fn GetPosition(&'a self) -> &'a b2Vec2
pub fn GetPosition(&'a self) -> &'a b2Vec2
Get the world body origin position. @return the world position of the body’s origin.
source§impl<'a> b2Body
impl<'a> b2Body
sourcepub fn GetWorldCenter(&'a self) -> &'a b2Vec2
pub fn GetWorldCenter(&'a self) -> &'a b2Vec2
Get the world position of the center of mass.
source§impl<'a> b2Body
impl<'a> b2Body
sourcepub fn GetLocalCenter(&'a self) -> &'a b2Vec2
pub fn GetLocalCenter(&'a self) -> &'a b2Vec2
Get the local position of the center of mass.
source§impl b2Body
impl b2Body
sourcepub fn SetLinearVelocity(self: Pin<&mut Self>, v: &b2Vec2)
pub fn SetLinearVelocity(self: Pin<&mut Self>, v: &b2Vec2)
Set the linear velocity of the center of mass. @param v the new linear velocity of the center of mass.
source§impl<'a> b2Body
impl<'a> b2Body
sourcepub fn GetLinearVelocity(&'a self) -> &'a b2Vec2
pub fn GetLinearVelocity(&'a self) -> &'a b2Vec2
Get the linear velocity of the center of mass. @return the linear velocity of the center of mass.
source§impl b2Body
impl b2Body
sourcepub fn SetAngularVelocity(self: Pin<&mut Self>, omega: f32)
pub fn SetAngularVelocity(self: Pin<&mut Self>, omega: f32)
Set the angular velocity. @param omega the new angular velocity in radians/second.
source§impl b2Body
impl b2Body
sourcepub fn GetAngularVelocity(&self) -> f32
pub fn GetAngularVelocity(&self) -> f32
Get the angular velocity. @return the angular velocity in radians/second.
source§impl b2Body
impl b2Body
sourcepub fn ApplyForce(
self: Pin<&mut Self>,
force: &b2Vec2,
point: &b2Vec2,
wake: bool
)
pub fn ApplyForce( self: Pin<&mut Self>, force: &b2Vec2, point: &b2Vec2, wake: bool )
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body. @param force the world force vector, usually in Newtons (N). @param point the world position of the point of application. @param wake also wake up the body
source§impl b2Body
impl b2Body
sourcepub fn ApplyLinearImpulse(
self: Pin<&mut Self>,
impulse: &b2Vec2,
point: &b2Vec2,
wake: bool
)
pub fn ApplyLinearImpulse( self: Pin<&mut Self>, impulse: &b2Vec2, point: &b2Vec2, wake: bool )
Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body. @param impulse the world impulse vector, usually in N-seconds or kg-m/s. @param point the world position of the point of application. @param wake also wake up the body
source§impl b2Body
impl b2Body
sourcepub fn GetInertia(&self) -> f32
pub fn GetInertia(&self) -> f32
Get the rotational inertia of the body about the local origin. @return the rotational inertia, usually in kg-m^2.
source§impl b2Body
impl b2Body
sourcepub unsafe fn GetMassData(&self, data: *mut b2MassData)
pub unsafe fn GetMassData(&self, data: *mut b2MassData)
Get the mass data of the body. @return a struct containing the mass, inertia and center of the body.
source§impl b2Body
impl b2Body
sourcepub unsafe fn SetMassData(self: Pin<&mut Self>, data: *const b2MassData)
pub unsafe fn SetMassData(self: Pin<&mut Self>, data: *const b2MassData)
Set the mass properties to override the mass properties of the fixtures. Note that this changes the center of mass position. Note that creating or destroying fixtures can also alter the mass. This function has no effect if the body isn’t dynamic. @param data the mass properties.
source§impl b2Body
impl b2Body
sourcepub fn ResetMassData(self: Pin<&mut Self>)
pub fn ResetMassData(self: Pin<&mut Self>)
This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override the mass and you later want to reset the mass.
source§impl b2Body
impl b2Body
sourcepub fn GetWorldPoint(&self, localPoint: &b2Vec2) -> b2Vec2
pub fn GetWorldPoint(&self, localPoint: &b2Vec2) -> b2Vec2
Get the world coordinates of a point given the local coordinates. @param localPoint a point on the body measured relative the the body’s origin. @return the same point expressed in world coordinates.
source§impl b2Body
impl b2Body
sourcepub fn GetWorldVector(&self, localVector: &b2Vec2) -> b2Vec2
pub fn GetWorldVector(&self, localVector: &b2Vec2) -> b2Vec2
Get the world coordinates of a vector given the local coordinates. @param localVector a vector fixed in the body. @return the same vector expressed in world coordinates.
source§impl b2Body
impl b2Body
sourcepub fn GetLocalPoint(&self, worldPoint: &b2Vec2) -> b2Vec2
pub fn GetLocalPoint(&self, worldPoint: &b2Vec2) -> b2Vec2
Gets a local point relative to the body’s origin given a world point. @param worldPoint a point in world coordinates. @return the corresponding local point relative to the body’s origin.
source§impl b2Body
impl b2Body
sourcepub fn GetLocalVector(&self, worldVector: &b2Vec2) -> b2Vec2
pub fn GetLocalVector(&self, worldVector: &b2Vec2) -> b2Vec2
Gets a local vector given a world vector. @param worldVector a vector in world coordinates. @return the corresponding local vector.
source§impl b2Body
impl b2Body
sourcepub fn GetLinearVelocityFromWorldPoint(&self, worldPoint: &b2Vec2) -> b2Vec2
pub fn GetLinearVelocityFromWorldPoint(&self, worldPoint: &b2Vec2) -> b2Vec2
Get the world linear velocity of a world point attached to this body. @param worldPoint a point in world coordinates. @return the world velocity of a point.
source§impl b2Body
impl b2Body
sourcepub fn GetLinearVelocityFromLocalPoint(&self, localPoint: &b2Vec2) -> b2Vec2
pub fn GetLinearVelocityFromLocalPoint(&self, localPoint: &b2Vec2) -> b2Vec2
Get the world velocity of a local point. @param localPoint a point in local coordinates. @return the world velocity of a point.
source§impl b2Body
impl b2Body
sourcepub fn SetLinearDamping(self: Pin<&mut Self>, linearDamping: f32)
pub fn SetLinearDamping(self: Pin<&mut Self>, linearDamping: f32)
Set the linear damping of the body.
source§impl b2Body
impl b2Body
sourcepub fn SetAngularDamping(self: Pin<&mut Self>, angularDamping: f32)
pub fn SetAngularDamping(self: Pin<&mut Self>, angularDamping: f32)
Set the angular damping of the body.
source§impl b2Body
impl b2Body
sourcepub fn SetGravityScale(self: Pin<&mut Self>, scale: f32)
pub fn SetGravityScale(self: Pin<&mut Self>, scale: f32)
Set the gravity scale of the body.
source§impl b2Body
impl b2Body
sourcepub fn SetType(self: Pin<&mut Self>, type_: b2BodyType)
pub fn SetType(self: Pin<&mut Self>, type_: b2BodyType)
Set the type of this body. This may alter the mass and velocity.
source§impl b2Body
impl b2Body
sourcepub fn SetSleepingAllowed(self: Pin<&mut Self>, flag: bool)
pub fn SetSleepingAllowed(self: Pin<&mut Self>, flag: bool)
You can disable sleeping on this body. If you disable sleeping, the body will be woken.
source§impl b2Body
impl b2Body
sourcepub fn SetEnabled(self: Pin<&mut Self>, flag: bool)
pub fn SetEnabled(self: Pin<&mut Self>, flag: bool)
Allow a body to be disabled. A disabled body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on disabled bodies. Fixtures on a disabled body are implicitly disabled and will not participate in collisions, ray-casts, or queries. Joints connected to a disabled body are implicitly disabled. An diabled body is still owned by a b2World object and remains in the body list.
source§impl b2Body
impl b2Body
sourcepub fn SetFixedRotation(self: Pin<&mut Self>, flag: bool)
pub fn SetFixedRotation(self: Pin<&mut Self>, flag: bool)
Set this body to have fixed rotation. This causes the mass to be reset.
source§impl b2Body
impl b2Body
sourcepub fn GetJointList(self: Pin<&mut Self>) -> *mut b2JointEdge
pub fn GetJointList(self: Pin<&mut Self>) -> *mut b2JointEdge
Get the list of all joints attached to this body.
source§impl b2Body
impl b2Body
pub fn GetJointList1(&self) -> *const b2JointEdge
source§impl b2Body
impl b2Body
sourcepub fn GetContactList(self: Pin<&mut Self>) -> *mut b2ContactEdge
pub fn GetContactList(self: Pin<&mut Self>) -> *mut b2ContactEdge
Get the list of all contacts attached to this body. @warning this list changes during the time step and you may miss some collisions if you don’t use b2ContactListener.