| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Box3D.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 Quat
- getRotationInto :: BodyId -> Ptr Quat -> IO ()
- getTransform :: BodyId -> IO WorldTransform
- getTransformInto :: BodyId -> Ptr WorldTransform -> IO ()
- setTransform :: BodyId -> Pos -> Quat -> IO ()
- getLocalPoint :: BodyId -> Pos -> IO Vec3
- getWorldPoint :: BodyId -> Vec3 -> IO Pos
- getLocalVector :: BodyId -> Vec3 -> IO Vec3
- getWorldVector :: BodyId -> Vec3 -> IO Vec3
- getLinearVelocity :: BodyId -> IO Vec3
- getLinearVelocityInto :: BodyId -> Ptr Vec3 -> IO ()
- getAngularVelocity :: BodyId -> IO Vec3
- getAngularVelocityInto :: BodyId -> Ptr Vec3 -> IO ()
- setLinearVelocity :: BodyId -> Vec3 -> IO ()
- setAngularVelocity :: BodyId -> Vec3 -> IO ()
- setTargetTransform :: BodyId -> WorldTransform -> Float -> Bool -> IO ()
- getLocalPointVelocity :: BodyId -> Vec3 -> IO Vec3
- getWorldPointVelocity :: BodyId -> Pos -> IO Vec3
- applyForce :: BodyId -> Vec3 -> Pos -> Bool -> IO ()
- applyForceToCenter :: BodyId -> Vec3 -> Bool -> IO ()
- applyTorque :: BodyId -> Vec3 -> Bool -> IO ()
- applyLinearImpulse :: BodyId -> Vec3 -> Pos -> Bool -> IO ()
- applyLinearImpulseToCenter :: BodyId -> Vec3 -> Bool -> IO ()
- applyAngularImpulse :: BodyId -> Vec3 -> Bool -> IO ()
- getMass :: BodyId -> IO Float
- getLocalRotationalInertia :: BodyId -> IO Matrix3
- getLocalRotationalInertiaInto :: BodyId -> Ptr Matrix3 -> IO ()
- getInverseMass :: BodyId -> IO Float
- getWorldInverseRotationalInertia :: BodyId -> IO Matrix3
- getWorldInverseRotationalInertiaInto :: BodyId -> Ptr Matrix3 -> IO ()
- getLocalCenterOfMass :: BodyId -> IO Vec3
- getLocalCenterOfMassInto :: BodyId -> Ptr Vec3 -> IO ()
- getWorldCenterOfMass :: BodyId -> IO Pos
- getWorldCenterOfMassInto :: 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 ()
- 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
- 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 ()
- getClosestPoint :: BodyId -> Ptr Vec3 -> Vec3 -> IO Float
- castRay :: BodyId -> Pos -> Vec3 -> QueryFilter -> Float -> WorldTransform -> Ptr BodyCastResult -> IO ()
- castShape :: BodyId -> Pos -> Ptr ShapeProxy -> Vec3 -> QueryFilter -> Float -> Bool -> WorldTransform -> Ptr BodyCastResult -> IO ()
- overlapShape :: BodyId -> Pos -> Ptr ShapeProxy -> QueryFilter -> WorldTransform -> IO Bool
- collideMover :: BodyId -> Ptr BodyPlaneResult -> Int -> Pos -> Capsule -> QueryFilter -> WorldTransform -> IO Int
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.
Set the body name. Up to B3_BODY_NAME_LENGTH characters including null termination.
Binds b3Body_SetName.
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.
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.
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.
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 the intended transform. See also b3BodyDef::position and b3BodyDef::rotation.
Binds b3Body_SetTransform.
Get a local point on a body given a world point
Binds b3Body_GetLocalPoint.
Get a world point on a body given a local point
Binds b3Body_GetWorldPoint.
Get a local vector on a body given a world vector
Binds b3Body_GetLocalVector.
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 #
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 #
Like getAngularVelocity, but the result is written into a caller-supplied buffer.
Set the linear velocity of a body. Usually in meters per second.
Binds b3Body_SetLinearVelocity.
Set the angular velocity of a body in radians per second
Binds b3Body_SetAngularVelocity.
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 #
Get the linear velocity of a local point attached to a body. Usually in meters per second.
Binds b3Body_GetLocalPointVelocity.
getWorldPointVelocity Source #
Get the linear velocity of a world point attached to a body. Usually in meters per second.
Binds b3Body_GetWorldPointVelocity.
Arguments
| :: BodyId |
|
| -> Vec3 |
|
| -> 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 b3Body_ApplyForce.
Arguments
| :: BodyId |
|
| -> Vec3 |
|
| -> 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 b3Body_ApplyForceToCenter.
Arguments
| :: BodyId |
|
| -> Vec3 |
|
| -> 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 b3Body_ApplyTorque.
Arguments
| :: BodyId |
|
| -> Vec3 |
|
| -> 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 b3Body_ApplyLinearImpulse.
applyLinearImpulseToCenter Source #
Arguments
| :: BodyId |
|
| -> Vec3 |
|
| -> 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 b3Body_ApplyLinearImpulseToCenter.
Arguments
| :: BodyId |
|
| -> Vec3 |
|
| -> Bool |
|
| -> 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 #
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 #
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 #
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 #
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 b3Body_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 b3BodyDef::enableContactRecycling.
Binds b3Body_EnableContactRecycling.
isContactRecyclingEnabled :: BodyId -> IO Bool Source #
Is contact recycling enabled on this body?
Binds b3Body_IsContactRecyclingEnabled.
Enable/disable hit events on all shapes See also b3ShapeDef::enableHitEvents.
Binds b3Body_EnableHitEvents.
getShapeCount :: BodyId -> IO Int Source #
Get the number of shapes on this body
Binds b3Body_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 b3Body_GetShapes.
getJointCount :: BodyId -> IO Int Source #
Get the number of joints on this body
Binds b3Body_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 b3Body_GetJoints.
getContactCapacity :: BodyId -> IO Int Source #
Get the maximum capacity required for retrieving all the touching contacts on a body
Binds b3Body_GetContactCapacity.
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.
Like computeAABB, but the result is written into a caller-supplied buffer.
Get the closest point on a body to a world target.
Binds b3Body_GetClosestPoint.
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.
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.
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.
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.