| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Box2D.Shape
Synopsis
- createCircle :: BodyId -> ShapeDef -> Circle -> IO ShapeId
- createSegment :: BodyId -> ShapeDef -> Segment -> IO ShapeId
- createChainSegment :: BodyId -> ShapeDef -> Ptr ChainSegment -> IO ShapeId
- createCapsule :: BodyId -> ShapeDef -> Capsule -> IO ShapeId
- createPolygon :: BodyId -> ShapeDef -> Polygon -> IO ShapeId
- destroy :: ShapeId -> Bool -> IO ()
- isValid :: ShapeId -> IO Bool
- getType :: ShapeId -> IO ShapeType
- getBody :: ShapeId -> IO BodyId
- getWorld :: ShapeId -> IO WorldId
- isSensor :: ShapeId -> IO Bool
- setUserData :: ShapeId -> Ptr () -> IO ()
- getUserData :: ShapeId -> IO (Ptr ())
- setDensity :: ShapeId -> Float -> Bool -> IO ()
- getDensity :: ShapeId -> IO Float
- setFriction :: ShapeId -> Float -> IO ()
- getFriction :: ShapeId -> IO Float
- setRestitution :: ShapeId -> Float -> IO ()
- getRestitution :: ShapeId -> IO Float
- setUserMaterial :: ShapeId -> Word64 -> IO ()
- getUserMaterial :: ShapeId -> IO Word64
- setSurfaceMaterial :: ShapeId -> SurfaceMaterial -> IO ()
- getSurfaceMaterial :: ShapeId -> IO SurfaceMaterial
- getSurfaceMaterialInto :: ShapeId -> Ptr SurfaceMaterial -> IO ()
- getFilter :: ShapeId -> IO Filter
- getFilterInto :: ShapeId -> Ptr Filter -> IO ()
- setFilter :: ShapeId -> Filter -> IO ()
- enableSensorEvents :: ShapeId -> Bool -> IO ()
- areSensorEventsEnabled :: ShapeId -> IO Bool
- enableContactEvents :: ShapeId -> Bool -> IO ()
- areContactEventsEnabled :: ShapeId -> IO Bool
- enablePreSolveEvents :: ShapeId -> Bool -> IO ()
- arePreSolveEventsEnabled :: ShapeId -> IO Bool
- enableHitEvents :: ShapeId -> Bool -> IO ()
- areHitEventsEnabled :: ShapeId -> IO Bool
- testPoint :: ShapeId -> Pos -> IO Bool
- rayCast :: ShapeId -> Pos -> Vec2 -> IO WorldCastOutput
- getCircle :: ShapeId -> IO Circle
- getCircleInto :: ShapeId -> Ptr Circle -> IO ()
- getSegment :: ShapeId -> IO Segment
- getSegmentInto :: ShapeId -> Ptr Segment -> IO ()
- getChainSegment :: ShapeId -> Ptr ChainSegment -> IO ()
- getCapsule :: ShapeId -> IO Capsule
- getCapsuleInto :: ShapeId -> Ptr Capsule -> IO ()
- getPolygon :: ShapeId -> IO Polygon
- getPolygonInto :: ShapeId -> Ptr Polygon -> IO ()
- setCircle :: ShapeId -> Circle -> IO ()
- setCapsule :: ShapeId -> Capsule -> IO ()
- setSegment :: ShapeId -> Segment -> IO ()
- setPolygon :: ShapeId -> Polygon -> IO ()
- setChainSegment :: ShapeId -> Ptr ChainSegment -> IO ()
- getParentChain :: ShapeId -> IO ChainId
- getContactCapacity :: ShapeId -> IO Int
- getContactData :: ShapeId -> Ptr ContactData -> Int -> IO Int
- getSensorCapacity :: ShapeId -> IO Int
- getSensorData :: ShapeId -> Ptr ShapeId -> Int -> IO Int
- getAABB :: ShapeId -> IO AABB
- getAABBInto :: ShapeId -> Ptr AABB -> IO ()
- computeMassData :: ShapeId -> IO MassData
- computeMassDataInto :: ShapeId -> Ptr MassData -> IO ()
- getClosestPoint :: ShapeId -> Pos -> IO Pos
- applyWind :: ShapeId -> Vec2 -> Float -> Float -> Bool -> IO ()
Documentation
createCircle :: BodyId -> ShapeDef -> Circle -> IO ShapeId Source #
Create a circle shape and attach it to a body. The shape definition and geometry are fully cloned. Contacts are not created until the next time step.
Returns: the shape id for accessing the shape
Binds b2CreateCircleShape.
createSegment :: BodyId -> ShapeDef -> Segment -> IO ShapeId Source #
Create a line segment shape and attach it to a body. The shape definition and geometry are fully cloned. Contacts are not created until the next time step.
Returns: the shape id or b2_nullShapeId if the segment is too short.
Binds b2CreateSegmentShape.
createChainSegment :: BodyId -> ShapeDef -> Ptr ChainSegment -> IO ShapeId Source #
Create an orphaned chain segment shape and attach it to a body. The shape definition and geometry are fully cloned. The caller is responsible for the segment's ghost vertices and lifetime. The segment is not owned by any b2ChainShape (b2Shape_GetParentChain returns b2_nullChainId). Contacts are not created until the next time step.
Returns: the shape id, or b2_nullShapeId if the segment is too short.
Binds b2CreateChainSegmentShape.
createCapsule :: BodyId -> ShapeDef -> Capsule -> IO ShapeId Source #
Create a capsule shape and attach it to a body. The shape definition and geometry are fully cloned. Contacts are not created until the next time step.
Returns: the shape id for accessing the shape, this will be b2_nullShapeId if the length is too small.
Binds b2CreateCapsuleShape.
createPolygon :: BodyId -> ShapeDef -> Polygon -> IO ShapeId Source #
Create a polygon shape and attach it to a body. The shape definition and geometry are fully cloned. Contacts are not created until the next time step.
Returns: the shape id for accessing the shape
Binds b2CreatePolygonShape.
Destroy a shape. You may defer the body mass update which can improve performance if several shapes on a body are destroyed at once. See also b2Body_ApplyMassFromShapes.
Binds b2DestroyShape.
isValid :: ShapeId -> IO Bool Source #
Shape identifier validation. Provides validation for up to 64K allocations.
Binds b2Shape_IsValid.
getBody :: ShapeId -> IO BodyId Source #
Get the id of the body that a shape is attached to
Binds b2Shape_GetBody.
isSensor :: ShapeId -> IO Bool Source #
Returns true if the shape is a sensor. It is not possible to change a shape from sensor to solid dynamically because this breaks the contract for sensor events.
Binds b2Shape_IsSensor.
Set the user data for a shape
Binds b2Shape_SetUserData.
getUserData :: ShapeId -> IO (Ptr ()) Source #
Get the user data for a shape. This is useful when you get a shape id from an event or query.
Binds b2Shape_GetUserData.
Set the mass density of a shape, usually in kg/m^2. This will optionally update the mass properties on the parent body. See also b2ShapeDef::density, b2Body_ApplyMassFromShapes.
Binds b2Shape_SetDensity.
getDensity :: ShapeId -> IO Float Source #
Get the density of a shape, usually in kg/m^2
Binds b2Shape_GetDensity.
Set the friction on a shape
Binds b2Shape_SetFriction.
Set the shape restitution (bounciness)
Binds b2Shape_SetRestitution.
getRestitution :: ShapeId -> IO Float Source #
Get the shape restitution
Binds b2Shape_GetRestitution.
Set the user material identifier
Binds b2Shape_SetUserMaterial.
getUserMaterial :: ShapeId -> IO Word64 Source #
Get the user material identifier
Binds b2Shape_GetUserMaterial.
setSurfaceMaterial :: ShapeId -> SurfaceMaterial -> IO () Source #
Set the shape surface material
Binds b2Shape_SetSurfaceMaterial.
getSurfaceMaterial :: ShapeId -> IO SurfaceMaterial Source #
Get the shape surface material
Binds b2Shape_GetSurfaceMaterial.
getSurfaceMaterialInto Source #
Arguments
| :: ShapeId | |
| -> Ptr SurfaceMaterial | Result buffer. |
| -> IO () |
Like getSurfaceMaterial, but the result is written into a caller-supplied buffer.
Like getFilter, but the result is written into a caller-supplied buffer.
setFilter :: ShapeId -> Filter -> IO () Source #
Set the current filter. This is almost as expensive as recreating the shape. This may cause contacts to be immediately destroyed. However contacts are not created until the next world step. Sensor overlap state is also not updated until the next world step. See also b2ShapeDef::filter.
Binds b2Shape_SetFilter.
Enable sensor events for this shape. See also b2ShapeDef::enableSensorEvents.
Binds b2Shape_EnableSensorEvents.
areSensorEventsEnabled :: ShapeId -> IO Bool Source #
Returns true if sensor events are enabled.
Binds b2Shape_AreSensorEventsEnabled.
Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. See also b2ShapeDef::enableContactEvents. Warning: changing this at run-time may lead to lost begin/end events
Binds b2Shape_EnableContactEvents.
areContactEventsEnabled :: ShapeId -> IO Bool Source #
Returns true if contact events are enabled
Binds b2Shape_AreContactEventsEnabled.
Enable pre-solve contact events for this shape. Only applies to dynamic bodies. These are expensive and must be carefully handled due to multithreading. Ignored for sensors. See also b2PreSolveFcn.
Binds b2Shape_EnablePreSolveEvents.
arePreSolveEventsEnabled :: ShapeId -> IO Bool Source #
Returns true if pre-solve events are enabled
Binds b2Shape_ArePreSolveEventsEnabled.
Enable contact hit events for this shape. Ignored for sensors. See also b2WorldDef.hitEventThreshold.
Binds b2Shape_EnableHitEvents.
areHitEventsEnabled :: ShapeId -> IO Bool Source #
Returns true if hit events are enabled
Binds b2Shape_AreHitEventsEnabled.
Test a world point for overlap with a shape
Binds b2Shape_TestPoint.
Arguments
| :: ShapeId | |
| -> Pos | origin |
| -> Vec2 | translation |
| -> IO WorldCastOutput |
Ray cast a single shape. The ray starts at the origin and extends by the translation. The output point is a world position.
Binds b2Shape_RayCast.
getCircle :: ShapeId -> IO Circle Source #
Get a copy of the shape's circle. Asserts the type is correct.
Binds b2Shape_GetCircle.
Like getCircle, but the result is written into a caller-supplied buffer.
getSegment :: ShapeId -> IO Segment Source #
Get a copy of the shape's line segment. Asserts the type is correct.
Binds b2Shape_GetSegment.
Like getSegment, but the result is written into a caller-supplied buffer.
Arguments
| :: ShapeId | |
| -> Ptr ChainSegment | Result buffer. |
| -> IO () |
Get a copy of the shape's chain segment. These come from chain shapes. Asserts the type is correct.
Binds b2Shape_GetChainSegment.
getCapsule :: ShapeId -> IO Capsule Source #
Get a copy of the shape's capsule. Asserts the type is correct.
Binds b2Shape_GetCapsule.
Like getCapsule, but the result is written into a caller-supplied buffer.
getPolygon :: ShapeId -> IO Polygon Source #
Get a copy of the shape's convex polygon. Asserts the type is correct.
Binds b2Shape_GetPolygon.
Like getPolygon, but the result is written into a caller-supplied buffer.
setCircle :: ShapeId -> Circle -> IO () Source #
Allows you to change a shape to be a circle or update the current circle. This does not modify the mass properties. See also b2Body_ApplyMassFromShapes.
Binds b2Shape_SetCircle.
setCapsule :: ShapeId -> Capsule -> IO () Source #
Allows you to change a shape to be a capsule or update the current capsule. This does not modify the mass properties. See also b2Body_ApplyMassFromShapes.
Binds b2Shape_SetCapsule.
setSegment :: ShapeId -> Segment -> IO () Source #
Allows you to change a shape to be a segment or update the current segment.
Binds b2Shape_SetSegment.
setPolygon :: ShapeId -> Polygon -> IO () Source #
Allows you to change a shape to be a polygon or update the current polygon. This does not modify the mass properties. See also b2Body_ApplyMassFromShapes.
Binds b2Shape_SetPolygon.
setChainSegment :: ShapeId -> Ptr ChainSegment -> IO () Source #
Allows you to change a shape to be an orphaned chain segment or update the current chain segment, including its ghost vertices. The chainId on the input is ignored. The resulting shape is always orphaned. Asserts if the shape is already a chain segment owned by a b2ChainShape (chainId != B2_NULL_INDEX).
Binds b2Shape_SetChainSegment.
getParentChain :: ShapeId -> IO ChainId Source #
Get the parent chain id if the shape type is a chain segment, otherwise returns b2_nullChainId.
Binds b2Shape_GetParentChain.
getContactCapacity :: ShapeId -> IO Int Source #
Get the maximum capacity required for retrieving all the touching contacts on a shape
Binds b2Shape_GetContactCapacity.
Get the touching contact data for a shape. The provided shapeId will be either shapeIdA or shapeIdB on the contact data. 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 b2Shape_GetContactData.
Get the maximum capacity required for retrieving all the overlapped shapes on a sensor shape. This returns 0 if the provided shape is not a sensor.
Returns: the required capacity to get all the overlaps in b2Shape_GetSensorData
Binds b2Shape_GetSensorCapacity.
Arguments
| :: ShapeId |
|
| -> Ptr ShapeId |
|
| -> Int |
|
| -> IO Int |
Get the overlap data for a sensor shape computed the previous world step. Warning: do not ignore the return value, it specifies the valid number of elements Warning: overlaps may contain destroyed shapes so use b2Shape_IsValid to confirm each overlap
Returns: the number of elements filled in the provided array
Binds b2Shape_GetSensorData.
Like getAABB, but the result is written into a caller-supplied buffer.
computeMassData :: ShapeId -> IO MassData Source #
Compute the mass data for a shape
Binds b2Shape_ComputeMassData.
Like computeMassData, but the result is written into a caller-supplied buffer.
Get the closest point on a shape to a target point. Target and result are world positions. todo need sample
Binds b2Shape_GetClosestPoint.
Arguments
| :: ShapeId |
|
| -> Vec2 |
|
| -> Float |
|
| -> Float |
|
| -> Bool |
|
| -> IO () |
Apply a wind force to the body for this shape using the density of air. This considers the projected area of the shape in the wind direction. This also considers the relative velocity of the shape.
Binds b2Shape_ApplyWind.