| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Box2D.Body
Synopsis
- create :: WorldId -> BodyDef -> IO BodyId
- destroy :: BodyId -> IO ()
- isValid :: BodyId -> IO Bool
- getType :: BodyId -> IO BodyType
- setType :: BodyId -> BodyType -> IO ()
- setName :: BodyId -> CString -> IO ()
- getName :: BodyId -> IO CString
- setUserData :: BodyId -> Ptr () -> IO ()
- getUserData :: BodyId -> IO (Ptr ())
- getPosition :: BodyId -> IO Pos
- getPositionInto :: BodyId -> Ptr Pos -> IO ()
- getRotation :: BodyId -> IO Rot
- getRotationInto :: BodyId -> Ptr Rot -> IO ()
- getTransform :: BodyId -> IO WorldTransform
- getTransformInto :: BodyId -> Ptr WorldTransform -> IO ()
- setTransform :: BodyId -> Pos -> Rot -> IO ()
- getLocalPoint :: BodyId -> Pos -> IO Vec2
- getWorldPoint :: BodyId -> Vec2 -> IO Pos
- getLocalVector :: BodyId -> Vec2 -> IO Vec2
- getWorldVector :: BodyId -> Vec2 -> IO Vec2
- getLinearVelocity :: BodyId -> IO Vec2
- getLinearVelocityInto :: BodyId -> Ptr Vec2 -> IO ()
- getAngularVelocity :: BodyId -> IO Float
- setLinearVelocity :: BodyId -> Vec2 -> IO ()
- setAngularVelocity :: BodyId -> Float -> IO ()
- setTargetTransform :: BodyId -> WorldTransform -> Float -> Bool -> IO ()
- getLocalPointVelocity :: BodyId -> Vec2 -> IO Vec2
- getWorldPointVelocity :: BodyId -> Pos -> IO Vec2
- applyForce :: BodyId -> Vec2 -> Pos -> Bool -> IO ()
- applyForceToCenter :: BodyId -> Vec2 -> Bool -> IO ()
- applyTorque :: BodyId -> Float -> Bool -> IO ()
- clearForces :: BodyId -> IO ()
- applyLinearImpulse :: BodyId -> Vec2 -> Pos -> Bool -> IO ()
- applyLinearImpulseToCenter :: BodyId -> Vec2 -> Bool -> IO ()
- applyAngularImpulse :: BodyId -> Float -> Bool -> IO ()
- getMass :: BodyId -> IO Float
- getRotationalInertia :: BodyId -> IO Float
- getLocalCenter :: BodyId -> IO Vec2
- getLocalCenterInto :: BodyId -> Ptr Vec2 -> IO ()
- getWorldCenter :: BodyId -> IO Pos
- getWorldCenterInto :: BodyId -> Ptr Pos -> IO ()
- setMassData :: BodyId -> MassData -> IO ()
- getMassData :: BodyId -> IO MassData
- getMassDataInto :: BodyId -> Ptr MassData -> IO ()
- applyMassFromShapes :: BodyId -> IO ()
- setLinearDamping :: BodyId -> Float -> IO ()
- getLinearDamping :: BodyId -> IO Float
- setAngularDamping :: BodyId -> Float -> IO ()
- getAngularDamping :: BodyId -> IO Float
- setGravityScale :: BodyId -> Float -> IO ()
- getGravityScale :: BodyId -> IO Float
- isAwake :: BodyId -> IO Bool
- setAwake :: BodyId -> Bool -> IO ()
- wakeTouching :: BodyId -> IO ()
- enableSleep :: BodyId -> Bool -> IO ()
- isSleepEnabled :: BodyId -> IO Bool
- setSleepThreshold :: BodyId -> Float -> IO ()
- getSleepThreshold :: BodyId -> IO Float
- isEnabled :: BodyId -> IO Bool
- disable :: BodyId -> IO ()
- enable :: BodyId -> IO ()
- setMotionLocks :: BodyId -> MotionLocks -> IO ()
- getMotionLocks :: BodyId -> IO MotionLocks
- getMotionLocksInto :: BodyId -> Ptr MotionLocks -> IO ()
- setBullet :: BodyId -> Bool -> IO ()
- isBullet :: BodyId -> IO Bool
- enableContactRecycling :: BodyId -> Bool -> IO ()
- isContactRecyclingEnabled :: BodyId -> IO Bool
- enableContactEvents :: BodyId -> Bool -> IO ()
- enableHitEvents :: BodyId -> Bool -> IO ()
- getWorld :: BodyId -> IO WorldId
- getShapeCount :: BodyId -> IO Int
- getShapes :: BodyId -> Ptr ShapeId -> Int -> IO Int
- getJointCount :: BodyId -> IO Int
- getJoints :: BodyId -> Ptr JointId -> Int -> IO Int
- getContactCapacity :: BodyId -> IO Int
- getContactData :: BodyId -> Ptr ContactData -> Int -> IO Int
- computeAABB :: BodyId -> IO AABB
- computeAABBInto :: BodyId -> Ptr AABB -> IO ()
Documentation
create :: WorldId -> BodyDef -> IO BodyId Source #
Create a rigid body given a definition. No reference to the definition is retained. So you can create the definition on the stack and pass it as a pointer. b2BodyDef bodyDef = b2DefaultBodyDef(); b2BodyId myBodyId = b2CreateBody(myWorldId, &bodyDef); Warning: This function is locked during callbacks.
Binds b2CreateBody.
destroy :: BodyId -> IO () Source #
Destroy a rigid body given an id. This destroys all shapes and joints attached to the body. Do not keep references to the associated shapes and joints.
Binds b2DestroyBody.
isValid :: BodyId -> IO Bool Source #
Body identifier validation. A valid body exists in a world and is non-null. This can be used to detect orphaned ids. Provides validation for up to 64K allocations.
Binds b2Body_IsValid.
getType :: BodyId -> IO BodyType Source #
Get the body type: static, kinematic, or dynamic
Binds b2Body_GetType.
setType :: BodyId -> BodyType -> IO () Source #
Change the body type. This is an expensive operation. This automatically updates the mass properties regardless of the automatic mass setting.
Binds b2Body_SetType.
Set the body name. Up to 31 characters excluding 0 termination.
Binds b2Body_SetName.
Set the user data for a body
Binds b2Body_SetUserData.
getUserData :: BodyId -> IO (Ptr ()) Source #
Get the user data stored in a body
Binds b2Body_GetUserData.
getPosition :: BodyId -> IO Pos Source #
Get the world position of a body. This is the location of the body origin.
Binds b2Body_GetPosition.
Like getPosition, but the result is written into a caller-supplied buffer.
getRotation :: BodyId -> IO Rot Source #
Get the world rotation of a body as a cosine/sine pair (complex number)
Binds b2Body_GetRotation.
Like getRotation, but the result is written into a caller-supplied buffer.
getTransform :: BodyId -> IO WorldTransform Source #
Get the world transform of a body.
Binds b2Body_GetTransform.
Arguments
| :: BodyId | |
| -> Ptr WorldTransform | Result buffer. |
| -> IO () |
Like getTransform, but the result is written into a caller-supplied buffer.
Set the world transform of a body. This acts as a teleport and is fairly expensive. Note: Generally you should create a body with then intended transform. See also b2BodyDef::position and b2BodyDef::rotation.
Binds b2Body_SetTransform.
Get a local point on a body given a world point
Binds b2Body_GetLocalPoint.
Get a world point on a body given a local point
Binds b2Body_GetWorldPoint.
Get a local vector on a body given a world vector
Binds b2Body_GetLocalVector.
Get a world vector on a body given a local vector
Binds b2Body_GetWorldVector.
getLinearVelocity :: BodyId -> IO Vec2 Source #
Get the linear velocity of a body's center of mass. Usually in meters per second.
Binds b2Body_GetLinearVelocity.
getLinearVelocityInto Source #
Like getLinearVelocity, but the result is written into a caller-supplied buffer.
getAngularVelocity :: BodyId -> IO Float Source #
Get the angular velocity of a body in radians per second
Binds b2Body_GetAngularVelocity.
Set the linear velocity of a body. Usually in meters per second.
Binds b2Body_SetLinearVelocity.
Set the angular velocity of a body in radians per second
Binds b2Body_SetAngularVelocity.
Arguments
| :: BodyId |
|
| -> WorldTransform |
|
| -> Float |
|
| -> Bool |
|
| -> IO () |
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 and the body is currently asleep.
Binds b2Body_SetTargetTransform.
getLocalPointVelocity Source #
Get the linear velocity of a local point attached to a body. Usually in meters per second.
Binds b2Body_GetLocalPointVelocity.
getWorldPointVelocity Source #
Get the linear velocity of a world point attached to a body. Usually in meters per second.
Binds b2Body_GetWorldPointVelocity.
Arguments
| :: BodyId |
|
| -> Vec2 |
|
| -> Pos |
|
| -> Bool |
|
| -> IO () |
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 optionally wakes up the body. The force is ignored if the body is not awake.
Binds b2Body_ApplyForce.
Arguments
| :: BodyId |
|
| -> Vec2 |
|
| -> Bool |
|
| -> IO () |
Apply a force to the center of mass. This optionally wakes up the body. The force is ignored if the body is not awake.
Binds b2Body_ApplyForceToCenter.
Arguments
| :: BodyId |
|
| -> Float |
|
| -> Bool |
|
| -> IO () |
Apply a torque. This affects the angular velocity without affecting the linear velocity. This optionally wakes the body. The torque is ignored if the body is not awake.
Binds b2Body_ApplyTorque.
Clear the force and torque on this body. Forces and torques are automatically cleared after each world step. So this only needs to be called if the application wants to remove the effect of previous calls to apply forces and torques before the world step is called.
Binds b2Body_ClearForces.
Arguments
| :: BodyId |
|
| -> Vec2 |
|
| -> Pos |
|
| -> Bool |
|
| -> IO () |
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 optionally wakes 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.
Binds b2Body_ApplyLinearImpulse.
applyLinearImpulseToCenter Source #
Arguments
| :: BodyId |
|
| -> Vec2 |
|
| -> Bool |
|
| -> IO () |
Apply an impulse to the center of mass. This immediately modifies the velocity. The impulse is ignored if the body is not awake. This optionally wakes the body. 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.
Binds b2Body_ApplyLinearImpulseToCenter.
Arguments
| :: BodyId |
|
| -> Float |
|
| -> Bool |
|
| -> IO () |
Apply an angular impulse. The impulse is ignored if the body is not awake. This optionally wakes the body. Warning: This should be used for one-shot impulses. If you need a steady torque, use a torque instead, which will work better with the sub-stepping solver.
Binds b2Body_ApplyAngularImpulse.
getMass :: BodyId -> IO Float Source #
Get the mass of the body, usually in kilograms
Binds b2Body_GetMass.
getRotationalInertia :: BodyId -> IO Float Source #
Get the rotational inertia of the body, usually in kg*m^2
Binds b2Body_GetRotationalInertia.
getLocalCenter :: BodyId -> IO Vec2 Source #
Get the center of mass position of the body in local space.
Binds b2Body_GetLocalCenter.
Like getLocalCenter, but the result is written into a caller-supplied buffer.
getWorldCenter :: BodyId -> IO Pos Source #
Get the center of mass position of the body in world space.
Binds b2Body_GetWorldCenter.
Like getWorldCenter, but the result is written into a caller-supplied buffer.
setMassData :: BodyId -> MassData -> IO () Source #
Override the body's mass properties. Normally this is computed automatically using the shape geometry and density. This information is lost if a shape is added or removed or if the body type changes.
Binds b2Body_SetMassData.
Like getMassData, but the result is written into a caller-supplied buffer.
applyMassFromShapes :: BodyId -> IO () Source #
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 that sensor shapes may have mass.
Binds b2Body_ApplyMassFromShapes.
Adjust the linear damping. Normally this is set in b2BodyDef before creation.
Binds b2Body_SetLinearDamping.
getLinearDamping :: BodyId -> IO Float Source #
Get the current linear damping.
Binds b2Body_GetLinearDamping.
Adjust the angular damping. Normally this is set in b2BodyDef before creation.
Binds b2Body_SetAngularDamping.
getAngularDamping :: BodyId -> IO Float Source #
Get the current angular damping.
Binds b2Body_GetAngularDamping.
Adjust the gravity scale. Normally this is set in b2BodyDef before creation. See also b2BodyDef::gravityScale.
Binds b2Body_SetGravityScale.
getGravityScale :: BodyId -> IO Float Source #
Get the current gravity scale
Binds b2Body_GetGravityScale.
Wake a body from sleep. 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.
Binds b2Body_SetAwake.
wakeTouching :: BodyId -> IO () Source #
Wake bodies touching this body. Works for static bodies.
Binds b2Body_WakeTouching.
Enable or disable sleeping for this body. If sleeping is disabled the body will wake (and the entire island).
Binds b2Body_EnableSleep.
isSleepEnabled :: BodyId -> IO Bool Source #
Returns true if sleeping is enabled for this body
Binds b2Body_IsSleepEnabled.
Set the sleep threshold, usually in meters per second
Binds b2Body_SetSleepThreshold.
getSleepThreshold :: BodyId -> IO Float Source #
Get the sleep threshold, usually in meters per second.
Binds b2Body_GetSleepThreshold.
disable :: BodyId -> IO () Source #
Disable a body by removing it completely from the simulation. This is expensive.
Binds b2Body_Disable.
enable :: BodyId -> IO () Source #
Enable a body by adding it to the simulation. This is expensive.
Binds b2Body_Enable.
setMotionLocks :: BodyId -> MotionLocks -> IO () Source #
Set the motion locks on this body.
Binds b2Body_SetMotionLocks.
getMotionLocks :: BodyId -> IO MotionLocks Source #
Get the motion locks for this body.
Binds b2Body_GetMotionLocks.
Arguments
| :: BodyId | |
| -> Ptr MotionLocks | Result buffer. |
| -> IO () |
Like getMotionLocks, but the result is written into a caller-supplied buffer.
Set this body to be a bullet. A bullet does continuous collision detection against dynamic bodies (but not other bullets).
Binds b2Body_SetBullet.
enableContactRecycling Source #
Enable or disable contact recycling for this body. Contact recycling is a performance optimization that reuses contact manifolds when bodies move slightly. Disabling it can avoid ghost collisions on characters at the cost of higher per-step work. Existing contacts retain their prior setting; only contacts created after this call see the new value. See also b2BodyDef::enableContactRecycling.
Binds b2Body_EnableContactRecycling.
isContactRecyclingEnabled :: BodyId -> IO Bool Source #
Is contact recycling enabled on this body?
Binds b2Body_IsContactRecyclingEnabled.
Enable/disable contact events on all shapes. See also b2ShapeDef::enableContactEvents. Warning: changing this at runtime may cause mismatched begin/end touch events
Binds b2Body_EnableContactEvents.
Enable/disable hit events on all shapes See also b2ShapeDef::enableHitEvents.
Binds b2Body_EnableHitEvents.
getShapeCount :: BodyId -> IO Int Source #
Get the number of shapes on this body
Binds b2Body_GetShapeCount.
Get the shape ids for all shapes on this body, up to the provided capacity.
Returns: the number of shape ids stored in the user array
Binds b2Body_GetShapes.
getJointCount :: BodyId -> IO Int Source #
Get the number of joints on this body
Binds b2Body_GetJointCount.
Get the joint ids for all joints on this body, up to the provided capacity
Returns: the number of joint ids stored in the user array
Binds b2Body_GetJoints.
getContactCapacity :: BodyId -> IO Int Source #
Get the maximum capacity required for retrieving all the touching contacts on a body
Binds b2Body_GetContactCapacity.
Get the touching contact data for a body. Note: Box2D uses speculative collision so some contact points may be separated. Warning: do not ignore the return value, it specifies the valid number of elements
Returns: the number of elements filled in the provided array
Binds b2Body_GetContactData.
computeAABB :: BodyId -> IO AABB Source #
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.
Binds b2Body_ComputeAABB.
Like computeAABB, but the result is written into a caller-supplied buffer.