HughPH.Box2D
Organised dotnet bindings for Box2D 3.1.1
|
A Box2D physics body. The body's transform is the base transform for all shapes attached to this body. More...
Inherits IEquatable< Body >, and IComparable< Body >.
Public Member Functions | |
Body (World world, BodyDef def) | |
Create a body in the supplied world using the supplied BodyDef. | |
bool | Equals (Body other) |
Check if two Body objects represent the same Body. | |
override bool | Equals (object? obj) |
Check if this Body object is equal to another object. | |
override int | GetHashCode () |
Get the hash code for this Body object. | |
bool | ReferenceEquals (Body other) |
Check if this Body object refers to the same Body as another Body object. | |
int | CompareTo (Body other) |
Compare this Body object with another Body object. | |
unsafe void | Destroy () |
Destroy this body. | |
unsafe Vec2 | GetLocalPoint (Vec2 worldPoint) |
Get a local point on a body given a world point. | |
unsafe Vec2 | GetWorldPoint (Vec2 localPoint) |
Get a world point on a body given a local point. | |
unsafe Vec2 | GetLocalVector (Vec2 worldVector) |
Get a local vector on a body given a world vector. | |
unsafe Vec2 | GetWorldVector (Vec2 localVector) |
Get a world vector on a body given a local vector. | |
unsafe void | SetTargetTransform (Transform target, float timeStep) |
Set the velocity to reach the given transform after a given time step. The result will be close but maybe not exact. This is meant for kinematic bodies. The target is not applied if the velocity would be below the sleep threshold. This will automatically wake the body if asleep. | |
unsafe Vec2 | GetLocalPointVelocity (Vec2 localPoint) |
Get the linear velocity of a local point attached to a body. | |
unsafe Vec2 | GetWorldPointVelocity (Vec2 worldPoint) |
Get the linear velocity of a world point attached to a body. | |
unsafe void | ApplyForce (Vec2 force, Vec2 point, bool wake) |
Apply a force at a world point. | |
unsafe void | ApplyForceToCenter (Vec2 force, bool wake) |
Apply a force to the center of mass. | |
unsafe void | ApplyTorque (float torque, bool wake) |
Apply a torque. | |
unsafe void | ApplyLinearImpulse (Vec2 impulse, Vec2 point, bool wake) |
Apply an impulse at a point. | |
unsafe void | ApplyLinearImpulseToCenter (Vec2 impulse, bool wake) |
Apply an impulse to the center of mass. | |
unsafe void | ApplyAngularImpulse (float impulse, bool wake) |
Apply an angular impulse. | |
unsafe void | ApplyMassFromShapes () |
This updates the mass properties to the sum of the mass properties of the shapes. | |
unsafe void | EnableContactEvents (bool flag) |
Enable/disable contact events on all shapes. | |
unsafe void | EnableHitEvents (bool flag) |
Enable/disable hit events on all shapes. | |
unsafe Shape | CreateShape (in ShapeDef def, in Circle circle) |
Creates a circle shape and attaches it to this body. | |
unsafe Shape | CreateShape (in ShapeDef def, in Segment segment) |
Creates a line segment shape and attaches it to this body. | |
unsafe Shape | CreateShape (in ShapeDef def, in Capsule capsule) |
Creates a capsule shape and attaches it to this body. | |
unsafe Shape | CreateShape (in ShapeDef def, in Polygon polygon) |
Creates a polygon shape and attaches it to this body. | |
unsafe ChainShape | CreateChain (ChainDef def) |
Creates a chain shape. | |
Static Public Member Functions | |
static bool | operator== (Body left, Body right) |
Check if two Body objects are equal. | |
static bool | operator!= (Body left, Body right) |
Check if two Body objects are not equal. | |
Properties | |
static IComparer< Body > | DefaultComparer = BodyComparer.Instance [get] |
Default comparer for Body instances. This is used for sorting and comparing Body instances. Using the default comparer is recommended to avoid boxing and unboxing overhead. | |
static IEqualityComparer< Body > | DefaultEqualityComparer = BodyComparer.Instance [get] |
Default equality comparer for Body instances. This is used for comparing Body instances. Using the default equality comparer is recommended to avoid boxing and unboxing overhead. | |
unsafe bool | Valid [get] |
Body identifier validation. | |
unsafe BodyType | Type [get, set] |
The body type: static, kinematic, or dynamic. | |
unsafe? string | Name [get, set] |
The body name. | |
unsafe? object | UserData [get, set] |
The user data object for this body. | |
unsafe Vec2 | Position [get] |
The world position of the body. | |
unsafe Rotation | Rotation [get] |
The world rotation of this body as a cosine/sine pair (complex number). | |
unsafe Transform | Transform [get, set] |
The world transform of this body. | |
unsafe Vec2 | LinearVelocity [get, set] |
The linear velocity of the body's center of mass. | |
unsafe float | AngularVelocity [get, set] |
The angular velocity of the body in radians per second. | |
unsafe float | Mass [get] |
The mass of the body, usually in kilograms. | |
unsafe float | RotationalInertia [get] |
The rotational inertia of the body, usually in kg*m². | |
unsafe Vec2 | LocalCenterOfMass [get] |
The center of mass position of the body in local space. | |
unsafe Vec2 | WorldCenterOfMass [get] |
The center of mass position of the body in world space. | |
unsafe MassData | MassData [get, set] |
The mass data for this body. | |
unsafe float | LinearDamping [get, set] |
The linear damping. | |
unsafe float | AngularDamping [get, set] |
The angular damping. | |
unsafe float | GravityScale [get, set] |
The gravity scale. | |
unsafe bool | Awake [get, set] |
The body awake state. | |
unsafe bool | SleepEnabled [get, set] |
Option to enable or disable sleeping for this body. | |
unsafe float | SleepThreshold [get, set] |
The sleep threshold, usually in meters per second. | |
unsafe bool | Enabled [get, set] |
The body enabled flag. | |
unsafe bool | FixedRotation [get, set] |
The fixed rotation flag of the body. | |
unsafe bool | Bullet [get, set] |
The bullet flag of the body. | |
unsafe World | World [get] |
The world that owns this body. | |
unsafe ReadOnlySpan< Shape > | Shapes [get] |
The shapes attached to this body. | |
unsafe ReadOnlySpan< Joint > | Joints [get] |
The joints attached to this body. | |
unsafe ReadOnlySpan< ContactData > | Contacts [get] |
The touching contact data for this body. | |
unsafe AABB | AABB [get] |
The current world AABB that contains all the attached shapes. | |
A Box2D physics body. The body's transform is the base transform for all shapes attached to this body.
Create a body in the supplied world using the supplied BodyDef.
world | The world in which to create the body |
def | The BodyDef to use to create the body |
|
inline |
Apply an angular impulse.
impulse | The angular impulse, usually in units of kg*m*m/s |
wake | Option to wake up the body |
The impulse is ignored if the body is not awake
Warning: This should be used for one-shot impulses. If you need a steady force, use a force instead, which will work better with the sub-stepping solver
|
inline |
Apply a force at a world point.
force | The world force vector, usually in newtons (N) |
point | The world position of the point of application |
wake | Option to wake up the body |
If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. The force is ignored if the body is not awake
|
inline |
Apply a force to the center of mass.
force | The world force vector, usually in newtons (N) |
wake | Option to wake up the body |
This wakes up the body
If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. The force is ignored if the body is not awake
|
inline |
Apply an impulse at a point.
impulse | The world impulse vector, usually in N*s or kg*m/s |
point | The world position of the point of application |
wake | Option to wake up the body |
This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. The impulse is ignored if the body is not awake
Warning: This should be used for one-shot impulses. If you need a steady force, use a force instead, which will work better with the sub-stepping solver
|
inline |
Apply an impulse to the center of mass.
impulse | The world impulse vector, usually in N*s or kg*m/s |
wake | Option to wake up the body |
This immediately modifies the velocity. The impulse is ignored if the body is not awake
Warning: This should be used for one-shot impulses. If you need a steady force, use a force instead, which will work better with the sub-stepping solver
|
inline |
This updates the mass properties to the sum of the mass properties of the shapes.
This normally does not need to be called unless you called SetMassData to override the mass, and you later want to reset the mass. You may also use this when automatic mass computation has been disabled. You should call this regardless of body type
Note: Sensor shapes may have mass.
|
inline |
Apply a torque.
torque | The torque about the z-axis (out of the screen), usually in N*m |
wake | Option to wake up the body |
This affects the angular velocity without affecting the linear velocity. The torque is ignored if the body is not awake
|
inline |
Compare this Body object with another Body object.
other | The other Body object to compare with |
|
inline |
Creates a chain shape.
def | The chain definition |
Creates a capsule shape and attaches it to this body.
def | The shape definition |
capsule | The capsule |
The shape definition and geometry are fully cloned. Contacts are not created until the next time step
Creates a circle shape and attaches it to this body.
def | The shape definition |
circle | The circle |
The shape definition and geometry are fully cloned. Contacts are not created until the next time step
Creates a polygon shape and attaches it to this body.
def | The shape definition |
polygon | The polygon |
The shape definition and geometry are fully cloned. Contacts are not created until the next time step
Creates a line segment shape and attaches it to this body.
def | The shape definition |
segment | The segment |
The shape definition and geometry are fully cloned. Contacts are not created until the next time step
|
inline |
Destroy this body.
This destroys all shapes and joints attached to the body. Do not keep references to the associated shapes and joints
|
inline |
Enable/disable contact events on all shapes.
flag | Option to enable or disable contact events on all shapes |
Warning: Changing this at runtime may cause mismatched begin/end touch events.
|
inline |
Enable/disable hit events on all shapes.
flag | Option to enable or disable hit events on all shapes |
bool Box2D.Body.Equals | ( | Body | other | ) |
Check if two Body objects represent the same Body.
other | The other Body object to compare with |
override bool Box2D.Body.Equals | ( | object? | obj | ) |
Check if this Body object is equal to another object.
obj | The object to compare with |
override int Box2D.Body.GetHashCode | ( | ) |
Get the hash code for this Body object.
unsafe Vec2 Box2D.Body.GetLocalPoint | ( | Vec2 | worldPoint | ) |
Get a local point on a body given a world point.
worldPoint | The world point |
|
inline |
Get the linear velocity of a local point attached to a body.
localPoint | The local point |
Usually in meters per second
unsafe Vec2 Box2D.Body.GetLocalVector | ( | Vec2 | worldVector | ) |
Get a local vector on a body given a world vector.
worldVector | The world vector |
unsafe Vec2 Box2D.Body.GetWorldPoint | ( | Vec2 | localPoint | ) |
Get a world point on a body given a local point.
localPoint | The local point |
|
inline |
Get the linear velocity of a world point attached to a body.
worldPoint | The world point |
Usually in meters per second
unsafe Vec2 Box2D.Body.GetWorldVector | ( | Vec2 | localVector | ) |
Get a world vector on a body given a local vector.
localVector | The local vector |
Check if two Body objects are not equal.
left | The first Body object |
right | The second Body object |
Check if two Body objects are equal.
left | The first Body object |
right | The second Body object |
bool Box2D.Body.ReferenceEquals | ( | Body | other | ) |
Check if this Body object refers to the same Body as another Body object.
other | The other Body object to compare with |
|
inline |
Set the velocity to reach the given transform after a given time step. The result will be close but maybe not exact. This is meant for kinematic bodies. The target is not applied if the velocity would be below the sleep threshold. This will automatically wake the body if asleep.
target | The target transform |
timeStep | The time step |
|
get |
The current world AABB that contains all the attached shapes.
Note that this may not encompass the body origin. If there are no shapes attached then the returned AABB is empty and centered on the body origin
|
getset |
The angular damping.
Normally this is set in BodyDef before creation
|
getset |
The angular velocity of the body in radians per second.
In radians per second
|
getset |
The body awake state.
This wakes the entire island the body is touching. Warning: Putting a body to sleep will put the entire island of bodies touching this body to sleep, which can be expensive and possibly unintuitive.
|
getset |
The bullet flag of the body.
A bullet does continuous collision detection against dynamic bodies (but not other bullets)
|
get |
The touching contact data for this body.
Note: Box2D uses speculative collision so some contact points may be separated.
|
getset |
The fixed rotation flag of the body.
Setting this causes the mass to be reset in all cases
|
getset |
The gravity scale.
Normally this is set in BodyDef before creation
|
getset |
The linear damping.
Normally this is set in BodyDef before creation
|
getset |
The linear velocity of the body's center of mass.
Usually in meters per second
|
get |
The world position of the body.
This is the location of the body origin
|
getset |
Option to enable or disable sleeping for this body.
If sleeping is disabled the body will wake
|
getset |
The world transform of this body.
Setting this acts as a teleport and is fairly expensive.
Note: Generally you should create a body with the intended transform.
|
get |
Body identifier validation.
Can be used to detect orphaned ids. Provides validation for up to 64K allocations