HughPH.Box2D
Organised dotnet bindings for Box2D 3.1.0
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
Box2D.BodyDef Class Referencesealed

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. More...

Public Member Functions

 BodyDef (BodyType type=BodyType.Static, Vec2 position=default, Rotation rotation=default, Vec2 linearVelocity=default, float angularVelocity=0f, float linearDamping=0f, float angularDamping=0f, float gravityScale=1f, float sleepThreshold=0.05f, bool enableSleep=true, bool isAwake=true, bool fixedRotation=false, bool isBullet=false, bool isEnabled=true, bool allowFastRotation=false, string? name=null, object? userData=null)
 Construct a Body Definition with the supplied values.
 
 BodyDef ()
 Construct a Body Definition with the default values.
 

Properties

ref BodyType Type [get]
 The body type: static, kinematic, or dynamic.
 
ref Vec2 Position [get]
 The 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.
 
ref Rotation Rotation [get]
 The initial world rotation of the body.
 
ref Vec2 LinearVelocity [get]
 The initial linear velocity of the body's origin. Usually in meters per second.
 
ref float AngularVelocity [get]
 The initial angular velocity of the body. Radians per second.
 
ref float LinearDamping [get]
 Linear 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.
 
ref float AngularDamping [get]
 Angular 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.
 
ref float GravityScale [get]
 Scale the gravity applied to this body. Non-dimensional.
 
ref float SleepThreshold [get]
 Sleep speed threshold, default is 0.05 meters per second.
 
string? Name [get, set]
 Optional body name for debugging. Up to 31 characters (excluding null termination)
 
object? UserData [get, set]
 Use this to store application specific body data.
 
bool EnableSleep [get, set]
 Set this flag to false if this body should never fall asleep.
 
bool IsAwake [get, set]
 Is this body initially awake or sleeping?
 
bool FixedRotation [get, set]
 Should this body be prevented from rotating? Useful for characters.
 
bool IsBullet [get, set]
 Treat this body as 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 may interfere with joint constraints.
 
bool IsEnabled [get, set]
 Used to disable a body. A disabled body does not move or collide.
 
bool AllowFastRotation [get, set]
 This allows this body to bypass rotational speed limits. Should only be used for circular objects, like wheels.
 

Detailed 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.

Constructor & Destructor Documentation

◆ BodyDef()

Box2D.BodyDef.BodyDef ( BodyType  type = BodyType::Static,
Vec2  position = default,
Rotation  rotation = default,
Vec2  linearVelocity = default,
float  angularVelocity = 0f,
float  linearDamping = 0f,
float  angularDamping = 0f,
float  gravityScale = 1f,
float  sleepThreshold = 0::05f,
bool  enableSleep = true,
bool  isAwake = true,
bool  fixedRotation = false,
bool  isBullet = false,
bool  isEnabled = true,
bool  allowFastRotation = false,
string?  name = null,
object?  userData = null 
)
inline

Construct a Body Definition with the supplied values.

Parameters
typeThe BodyType of the body.
positionThe initial world position of the body. Bodies should be created with the desired position.
rotationThe initial world rotation of the body.
linearVelocityThe initial linear velocity of the body's origin. Usually in meters per second.
angularVelocityThe initial angular velocity of the body. Radians per second.
linearDampingLinear 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.
angularDampingAngular 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.
gravityScaleScale the gravity applied to this body. Non-dimensional.
sleepThresholdSleep speed threshold, default is 0.05 meters per second
enableSleepSet this flag to false if this body should never fall asleep.
isAwakeIs this body initially awake or sleeping?
fixedRotationShould this body be prevented from rotating? Useful for characters.
isBulletTreat this body as 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 may interfere with joint constraints.
isEnabledUsed to disable a body. A disabled body does not move or collide.
allowFastRotationThis allows this body to bypass rotational speed limits. Should only be used for circular objects, like wheels.
nameOptional body name for debugging. Up to 31 characters (excluding null termination)
userDataUse this to store application specific body data.

The documentation for this class was generated from the following file: