Box3D
Safe HaskellNone
LanguageGHC2021

Box3D.Body

Synopsis

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. b3BodyDef bodyDef = b3DefaultBodyDef(); b3BodyId myBodyId = b3CreateBody(myWorldId, &bodyDef); Warning: This function is locked during callbacks.

Binds b3CreateBody.

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

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

getType :: BodyId -> IO BodyType Source #

Get the body type: static, kinematic, or dynamic

Binds b3Body_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 b3Body_SetType.

setName Source #

Arguments

:: BodyId 
-> CString
name
-> IO () 

Set the body name. Up to B3_BODY_NAME_LENGTH characters including null termination.

Binds b3Body_SetName.

getName :: BodyId -> IO CString Source #

Get the body name.

Binds b3Body_GetName.

setUserData Source #

Arguments

:: BodyId 
-> Ptr ()
userData
-> IO () 

Set the user data for a body

Binds b3Body_SetUserData.

getUserData :: BodyId -> IO (Ptr ()) Source #

Get the user data stored in a body

Binds b3Body_GetUserData.

getPosition :: BodyId -> IO Pos Source #

Get the world position of a body. This is the location of the body origin.

Binds b3Body_GetPosition.

getPositionInto Source #

Arguments

:: BodyId 
-> Ptr Pos

Result buffer.

-> IO () 

Like getPosition, but the result is written into a caller-supplied buffer.

getRotation :: BodyId -> IO Quat Source #

Get the world rotation of a body as a quaternion

Binds b3Body_GetRotation.

getRotationInto Source #

Arguments

:: BodyId 
-> Ptr Quat

Result buffer.

-> IO () 

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

getTransformInto Source #

Arguments

:: BodyId 
-> Ptr WorldTransform

Result buffer.

-> IO () 

Like getTransform, but the result is written into a caller-supplied buffer.

setTransform Source #

Arguments

:: BodyId 
-> Pos
position
-> Quat
rotation
-> IO () 

Set the world transform of a body. This acts as a teleport and is fairly expensive. Note: Generally you should create a body with the intended transform. See also b3BodyDef::position and b3BodyDef::rotation.

Binds b3Body_SetTransform.

getLocalPoint Source #

Arguments

:: BodyId 
-> Pos
worldPoint
-> IO Vec3 

Get a local point on a body given a world point

Binds b3Body_GetLocalPoint.

getWorldPoint Source #

Arguments

:: BodyId 
-> Vec3
localPoint
-> IO Pos 

Get a world point on a body given a local point

Binds b3Body_GetWorldPoint.

getLocalVector Source #

Arguments

:: BodyId 
-> Vec3
worldVector
-> IO Vec3 

Get a local vector on a body given a world vector

Binds b3Body_GetLocalVector.

getWorldVector Source #

Arguments

:: BodyId 
-> Vec3
localVector
-> IO Vec3 

Get a world vector on a body given a local vector

Binds b3Body_GetWorldVector.

getLinearVelocity :: BodyId -> IO Vec3 Source #

Get the linear velocity of a body's center of mass. Usually in meters per second.

Binds b3Body_GetLinearVelocity.

getLinearVelocityInto Source #

Arguments

:: BodyId 
-> Ptr Vec3

Result buffer.

-> IO () 

Like getLinearVelocity, but the result is written into a caller-supplied buffer.

getAngularVelocity :: BodyId -> IO Vec3 Source #

Get the angular velocity of a body in radians per second

Binds b3Body_GetAngularVelocity.

getAngularVelocityInto Source #

Arguments

:: BodyId 
-> Ptr Vec3

Result buffer.

-> IO () 

Like getAngularVelocity, but the result is written into a caller-supplied buffer.

setLinearVelocity Source #

Arguments

:: BodyId 
-> Vec3
linearVelocity
-> IO () 

Set the linear velocity of a body. Usually in meters per second.

Binds b3Body_SetLinearVelocity.

setAngularVelocity Source #

Arguments

:: BodyId 
-> Vec3
angularVelocity
-> IO () 

Set the angular velocity of a body in radians per second

Binds b3Body_SetAngularVelocity.

setTargetTransform Source #

Arguments

:: BodyId 
-> WorldTransform
target
-> Float
timeStep
-> Bool
wake
-> 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. This will optionally wake the body if asleep, but only if the movement is significant.

Binds b3Body_SetTargetTransform.

getLocalPointVelocity Source #

Arguments

:: BodyId 
-> Vec3
localPoint
-> IO Vec3 

Get the linear velocity of a local point attached to a body. Usually in meters per second.

Binds b3Body_GetLocalPointVelocity.

getWorldPointVelocity Source #

Arguments

:: BodyId 
-> Pos
worldPoint
-> IO Vec3 

Get the linear velocity of a world point attached to a body. Usually in meters per second.

Binds b3Body_GetWorldPointVelocity.

applyForce Source #

Arguments

:: BodyId

bodyId: The body id

-> Vec3

force: The world force vector, usually in newtons (N)

-> Pos

point: The world position of the point of application

-> Bool

wake: Option to wake up the body

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

applyForceToCenter Source #

Arguments

:: BodyId

bodyId: The body id

-> Vec3

force: the world force vector, usually in newtons (N).

-> Bool

wake: also wake up the body

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

applyTorque Source #

Arguments

:: BodyId

bodyId: The body id

-> Vec3

torque: the world torque vector, usually in N*m.

-> Bool

wake: also wake up the body

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

applyLinearImpulse Source #

Arguments

:: BodyId

bodyId: The body id

-> Vec3

impulse: the world impulse vector, usually in N*s or kg*m/s.

-> Pos

point: the world position of the point of application.

-> Bool

wake: also wake up the body

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

applyLinearImpulseToCenter Source #

Arguments

:: BodyId

bodyId: The body id

-> Vec3

impulse: the world impulse vector, usually in N*s or kg*m/s.

-> Bool

wake: also wake up the body

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

applyAngularImpulse Source #

Arguments

:: BodyId

bodyId: The body id

-> Vec3

impulse: the world angular impulse vector, usually in units of kg*m*m/s

-> Bool

wake: also wake up the body

-> IO () 

Apply an angular impulse in world space. 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 b3Body_ApplyAngularImpulse.

getMass :: BodyId -> IO Float Source #

Get the mass of the body, usually in kilograms

Binds b3Body_GetMass.

getLocalRotationalInertia :: BodyId -> IO Matrix3 Source #

Get the rotational inertia of the body in local space, usually in kg*m^2

Binds b3Body_GetLocalRotationalInertia.

getLocalRotationalInertiaInto Source #

Arguments

:: BodyId 
-> Ptr Matrix3

Result buffer.

-> IO () 

Like getLocalRotationalInertia, but the result is written into a caller-supplied buffer.

getInverseMass :: BodyId -> IO Float Source #

Get the inverse mass of the body, usually in 1/kilograms

Binds b3Body_GetInverseMass.

getWorldInverseRotationalInertia :: BodyId -> IO Matrix3 Source #

Get the inverse rotational inertia of the body in world space, usually in 1/kg*m^2

Binds b3Body_GetWorldInverseRotationalInertia.

getWorldInverseRotationalInertiaInto Source #

Arguments

:: BodyId 
-> Ptr Matrix3

Result buffer.

-> IO () 

Like getWorldInverseRotationalInertia, but the result is written into a caller-supplied buffer.

getLocalCenterOfMass :: BodyId -> IO Vec3 Source #

Get the center of mass position of the body in local space

Binds b3Body_GetLocalCenterOfMass.

getLocalCenterOfMassInto Source #

Arguments

:: BodyId 
-> Ptr Vec3

Result buffer.

-> IO () 

Like getLocalCenterOfMass, but the result is written into a caller-supplied buffer.

getWorldCenterOfMass :: BodyId -> IO Pos Source #

Get the center of mass position of the body in world space

Binds b3Body_GetWorldCenterOfMass.

getWorldCenterOfMassInto Source #

Arguments

:: BodyId 
-> Ptr Pos

Result buffer.

-> IO () 

Like getWorldCenterOfMass, 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 b3Body_SetMassData.

getMassData :: BodyId -> IO MassData Source #

Get the mass data for a body

Binds b3Body_GetMassData.

getMassDataInto Source #

Arguments

:: BodyId 
-> Ptr MassData

Result buffer.

-> IO () 

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.

Binds b3Body_ApplyMassFromShapes.

setLinearDamping Source #

Arguments

:: BodyId 
-> Float
linearDamping
-> IO () 

Adjust the linear damping. Normally this is set in b3BodyDef before creation.

Binds b3Body_SetLinearDamping.

getLinearDamping :: BodyId -> IO Float Source #

Get the current linear damping.

Binds b3Body_GetLinearDamping.

setAngularDamping Source #

Arguments

:: BodyId 
-> Float
angularDamping
-> IO () 

Adjust the angular damping. Normally this is set in b3BodyDef before creation.

Binds b3Body_SetAngularDamping.

getAngularDamping :: BodyId -> IO Float Source #

Get the current angular damping.

Binds b3Body_GetAngularDamping.

setGravityScale Source #

Arguments

:: BodyId 
-> Float
gravityScale
-> IO () 

Adjust the gravity scale. Normally this is set in b3BodyDef before creation. See also b3BodyDef::gravityScale.

Binds b3Body_SetGravityScale.

getGravityScale :: BodyId -> IO Float Source #

Get the current gravity scale

Binds b3Body_GetGravityScale.

isAwake :: BodyId -> IO Bool Source #

Returns: true if this body is awake

Binds b3Body_IsAwake.

setAwake Source #

Arguments

:: BodyId 
-> Bool
awake
-> IO () 

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

enableSleep Source #

Arguments

:: BodyId 
-> Bool
enableSleep
-> IO () 

Enable or disable sleeping for this body. If sleeping is disabled the body will wake.

Binds b3Body_EnableSleep.

isSleepEnabled :: BodyId -> IO Bool Source #

Returns true if sleeping is enabled for this body

Binds b3Body_IsSleepEnabled.

setSleepThreshold Source #

Arguments

:: BodyId 
-> Float
sleepThreshold
-> IO () 

Set the sleep threshold, usually in meters per second

Binds b3Body_SetSleepThreshold.

getSleepThreshold :: BodyId -> IO Float Source #

Get the sleep threshold, usually in meters per second.

Binds b3Body_GetSleepThreshold.

isEnabled :: BodyId -> IO Bool Source #

Returns true if this body is enabled

Binds b3Body_IsEnabled.

disable :: BodyId -> IO () Source #

Disable a body by removing it completely from the simulation. This is expensive.

Binds b3Body_Disable.

enable :: BodyId -> IO () Source #

Enable a body by adding it to the simulation. This is expensive.

Binds b3Body_Enable.

setMotionLocks :: BodyId -> MotionLocks -> IO () Source #

Set the motion locks on this body.

Binds b3Body_SetMotionLocks.

getMotionLocks :: BodyId -> IO MotionLocks Source #

Get the motion locks for this body.

Binds b3Body_GetMotionLocks.

getMotionLocksInto Source #

Arguments

:: BodyId 
-> Ptr MotionLocks

Result buffer.

-> IO () 

Like getMotionLocks, but the result is written into a caller-supplied buffer.

setBullet Source #

Arguments

:: BodyId 
-> Bool
flag
-> IO () 

Set this body to be a bullet. A bullet does continuous collision detection against dynamic bodies (but not other bullets).

Binds b3Body_SetBullet.

isBullet :: BodyId -> IO Bool Source #

Is this body a bullet?

Binds b3Body_IsBullet.

enableContactRecycling Source #

Arguments

:: BodyId 
-> Bool
flag
-> IO () 

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 b3BodyDef::enableContactRecycling.

Binds b3Body_EnableContactRecycling.

isContactRecyclingEnabled :: BodyId -> IO Bool Source #

Is contact recycling enabled on this body?

Binds b3Body_IsContactRecyclingEnabled.

enableHitEvents Source #

Arguments

:: BodyId 
-> Bool
enableHitEvents
-> IO () 

Enable/disable hit events on all shapes See also b3ShapeDef::enableHitEvents.

Binds b3Body_EnableHitEvents.

getWorld :: BodyId -> IO WorldId Source #

Get the world that owns this body

Binds b3Body_GetWorld.

getShapeCount :: BodyId -> IO Int Source #

Get the number of shapes on this body

Binds b3Body_GetShapeCount.

getShapes Source #

Arguments

:: BodyId 
-> Ptr ShapeId
shapeArray
-> Int
capacity
-> IO Int 

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

getJointCount :: BodyId -> IO Int Source #

Get the number of joints on this body

Binds b3Body_GetJointCount.

getJoints Source #

Arguments

:: BodyId 
-> Ptr JointId
jointArray
-> Int
capacity
-> IO Int 

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

getContactCapacity :: BodyId -> IO Int Source #

Get the maximum capacity required for retrieving all the touching contacts on a body

Binds b3Body_GetContactCapacity.

getContactData Source #

Arguments

:: BodyId 
-> Ptr ContactData 
-> Int
capacity
-> IO Int 

Get the touching contact data for a body

Binds b3Body_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 b3Body_ComputeAABB.

computeAABBInto Source #

Arguments

:: BodyId 
-> Ptr AABB

Result buffer.

-> IO () 

Like computeAABB, but the result is written into a caller-supplied buffer.

getClosestPoint Source #

Arguments

:: BodyId 
-> Ptr Vec3
result
-> Vec3
target
-> IO Float 

Get the closest point on a body to a world target.

Binds b3Body_GetClosestPoint.

castRay Source #

Arguments

:: BodyId 
-> Pos
origin
-> Vec3
translation
-> QueryFilter 
-> Float
maxFraction
-> WorldTransform
bodyTransform
-> Ptr BodyCastResult

Result buffer.

-> IO () 

Cast a ray at a specific body using a specified body transform.

Binds b3Body_CastRay.

castShape Source #

Arguments

:: BodyId 
-> Pos
origin
-> Ptr ShapeProxy 
-> Vec3
translation
-> QueryFilter 
-> Float
maxFraction
-> Bool
canEncroach
-> WorldTransform
bodyTransform
-> Ptr BodyCastResult

Result buffer.

-> IO () 

Cast a shape at a specific body using a specified body transform.

Binds b3Body_CastShape.

overlapShape Source #

Arguments

:: BodyId 
-> Pos
origin
-> Ptr ShapeProxy 
-> QueryFilter 
-> WorldTransform
bodyTransform
-> IO Bool 

Overlap a shape with a specific body using a specified body transform.

Binds b3Body_OverlapShape.

collideMover Source #

Arguments

:: BodyId 
-> Ptr BodyPlaneResult
bodyPlanes
-> Int
planeCapacity
-> Pos
origin
-> Capsule
mover
-> QueryFilter 
-> WorldTransform
bodyTransform
-> IO Int 

Collide a character mover with a specific body using a specified body transform.

Binds b3Body_CollideMover.