#[repr(C, align(8))]
pub struct b2Body { /* private fields */ }
Expand description

A rigid body. These are created via b2World::CreateBody.

Implementations§

source§

impl b2Body

source

pub fn GetTransform(self: &b2Body) -> &b2Transform

Get the body transform for the body’s origin. @return the world transform of the body’s origin.

source

pub fn GetAngle(self: &b2Body) -> f32

Get the angle in radians. @return the current world rotation angle in radians.

source

pub fn GetType(self: &b2Body) -> b2BodyType

Get the type of this body.

source

pub fn GetNext(self: Pin<&mut b2Body>) -> *mut b2Body

Get the next body in the world’s body list.

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn GetWorldCenter(&'a self) -> &'a b2Vec2

Get the world position of the center of mass.

source§

impl<'a> b2Body

source

pub fn GetLocalCenter(&'a self) -> &'a b2Vec2

Get the local position of the center of mass.

source§

impl b2Body

source

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

source

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

source

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

source

pub fn GetAngularVelocity(&self) -> f32

Get the angular velocity. @return the angular velocity in radians/second.

source§

impl b2Body

source

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

source

pub fn ApplyForceToCenter(self: Pin<&mut Self>, force: &b2Vec2, wake: bool)

Apply a force to the center of mass. This wakes up the body. @param force the world force vector, usually in Newtons (N). @param wake also wake up the body

source§

impl b2Body

source

pub fn ApplyTorque(self: Pin<&mut Self>, torque: f32, wake: bool)

Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. @param torque about the z-axis (out of the screen), usually in N-m. @param wake also wake up the body

source§

impl b2Body

source

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

source

pub fn ApplyLinearImpulseToCenter( self: Pin<&mut Self>, impulse: &b2Vec2, wake: bool )

Apply an impulse to the center of mass. This immediately modifies the velocity. @param impulse the world impulse vector, usually in N-seconds or kg-m/s. @param wake also wake up the body

source§

impl b2Body

source

pub fn ApplyAngularImpulse(self: Pin<&mut Self>, impulse: f32, wake: bool)

Apply an angular impulse. @param impulse the angular impulse in units of kgmm/s @param wake also wake up the body

source§

impl b2Body

source

pub fn GetMass(&self) -> f32

Get the total mass of the body. @return the mass, usually in kilograms (kg).

source§

impl b2Body

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn GetLinearDamping(&self) -> f32

Get the linear damping of the body.

source§

impl b2Body

source

pub fn SetLinearDamping(self: Pin<&mut Self>, linearDamping: f32)

Set the linear damping of the body.

source§

impl b2Body

source

pub fn GetAngularDamping(&self) -> f32

Get the angular damping of the body.

source§

impl b2Body

source

pub fn SetAngularDamping(self: Pin<&mut Self>, angularDamping: f32)

Set the angular damping of the body.

source§

impl b2Body

source

pub fn GetGravityScale(&self) -> f32

Get the gravity scale of the body.

source§

impl b2Body

source

pub fn SetGravityScale(self: Pin<&mut Self>, scale: f32)

Set the gravity scale of the body.

source§

impl b2Body

source

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

source

pub fn SetBullet(self: Pin<&mut Self>, flag: bool)

Should this body be treated like a bullet for continuous collision detection?

source§

impl b2Body

source

pub fn IsBullet(&self) -> bool

Is this body treated like a bullet for continuous collision detection?

source§

impl b2Body

source

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

source

pub fn IsSleepingAllowed(&self) -> bool

Is this body allowed to sleep

source§

impl b2Body

source

pub fn SetAwake(self: Pin<&mut Self>, flag: bool)

Set the sleep state of the body. A sleeping body has very low CPU cost. @param flag set to true to wake the body, false to put it to sleep.

source§

impl b2Body

source

pub fn IsAwake(&self) -> bool

Get the sleeping state of this body. @return true if the body is awake.

source§

impl b2Body

source

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

source

pub fn IsEnabled(&self) -> bool

Get the active state of the body.

source§

impl b2Body

source

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

source

pub fn IsFixedRotation(&self) -> bool

Does this body have fixed rotation?

source§

impl b2Body

source

pub fn GetFixtureList(self: Pin<&mut Self>) -> *mut b2Fixture

Get the list of all fixtures attached to this body.

source§

impl b2Body

source§

impl b2Body

source

pub fn GetJointList(self: Pin<&mut Self>) -> *mut b2JointEdge

Get the list of all joints attached to this body.

source§

impl b2Body

source§

impl b2Body

source

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.

source§

impl b2Body

source§

impl b2Body

source

pub fn GetNext1(&self) -> *const b2Body

source§

impl b2Body

source

pub unsafe fn SetUserData(self: Pin<&mut Self>, data: *mut c_void)

Set the user data. Use this to store your application specific data.

source§

impl b2Body

source

pub fn GetWorld(self: Pin<&mut Self>) -> *mut b2World

Get the parent world of this body.

source§

impl b2Body

source§

impl b2Body

source

pub fn Dump(self: Pin<&mut Self>)

Dump this body to a file

Trait Implementations§

source§

impl CopyNew for b2Body

source§

unsafe fn copy_new(other: &b2Body, this: Pin<&mut MaybeUninit<b2Body>>)

Synthesized copy constructor.

source§

impl Debug for b2Body

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl ExternType for b2Body

§

type Id = (b, _2, B, o, d, y)

A type-level representation of the type’s C++ namespace and type name. Read more
§

type Kind = Opaque

source§

impl MakeCppStorage for b2Body

source§

unsafe fn allocate_uninitialized_cpp_storage() -> *mut b2Body

Allocates heap space for this type in C++ and return a pointer to that space, but do not initialize that space (i.e. do not yet call a constructor). Read more
source§

unsafe fn free_uninitialized_cpp_storage(arg0: *mut b2Body)

Frees a C++ allocation which has not yet had a constructor called. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for b2Body

§

impl !Send for b2Body

§

impl !Sync for b2Body

§

impl !Unpin for b2Body

§

impl UnwindSafe for b2Body

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.