| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Box3D.Shape
Synopsis
- createSphere :: BodyId -> ShapeDef -> Sphere -> IO ShapeId
- createCapsule :: BodyId -> ShapeDef -> Capsule -> IO ShapeId
- createHull :: BodyId -> ShapeDef -> Ptr HullData -> IO ShapeId
- createTransformedHull :: BodyId -> ShapeDef -> Ptr HullData -> Transform -> Vec3 -> IO ShapeId
- createMesh :: BodyId -> ShapeDef -> Ptr MeshData -> Vec3 -> IO ShapeId
- createHeightField :: BodyId -> ShapeDef -> Ptr HeightFieldData -> IO ShapeId
- createCompound :: BodyId -> Ptr ShapeDef -> Ptr CompoundData -> 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
- setSurfaceMaterial :: ShapeId -> SurfaceMaterial -> IO ()
- getSurfaceMaterial :: ShapeId -> IO SurfaceMaterial
- getSurfaceMaterialInto :: ShapeId -> Ptr SurfaceMaterial -> IO ()
- getMeshMaterialCount :: ShapeId -> IO Int
- setMeshMaterial :: ShapeId -> SurfaceMaterial -> Int -> IO ()
- getMeshSurfaceMaterial :: ShapeId -> Int -> IO SurfaceMaterial
- getMeshSurfaceMaterialInto :: ShapeId -> Int -> Ptr SurfaceMaterial -> IO ()
- getFilter :: ShapeId -> IO Filter
- getFilterInto :: ShapeId -> Ptr Filter -> IO ()
- setFilter :: ShapeId -> Filter -> Bool -> 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
- rayCast :: ShapeId -> Pos -> Vec3 -> IO WorldCastOutput
- getSphere :: ShapeId -> IO Sphere
- getSphereInto :: ShapeId -> Ptr Sphere -> IO ()
- getCapsule :: ShapeId -> IO Capsule
- getCapsuleInto :: ShapeId -> Ptr Capsule -> IO ()
- getHull :: ShapeId -> IO (Ptr HullData)
- getMesh :: ShapeId -> Ptr Mesh -> IO ()
- getHeightField :: ShapeId -> IO (Ptr HeightFieldData)
- setSphere :: ShapeId -> Sphere -> IO ()
- setCapsule :: ShapeId -> Capsule -> IO ()
- setHull :: ShapeId -> Ptr HullData -> IO ()
- setMesh :: ShapeId -> Ptr MeshData -> Vec3 -> IO ()
- 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 -> Vec3 -> IO Vec3
- applyWind :: ShapeId -> Vec3 -> Float -> Float -> Float -> Bool -> IO ()
Documentation
createSphere :: BodyId -> ShapeDef -> Sphere -> 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 b3CreateSphereShape.
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
Binds b3CreateCapsuleShape.
createHull :: BodyId -> ShapeDef -> Ptr HullData -> IO ShapeId Source #
Create a convex hull shape and attach it to a body. The shape definition is fully cloned. Contacts are not created until the next time step.
Returns: the shape id for accessing the shape
Binds b3CreateHullShape.
createTransformedHull Source #
Create a convex hull shape and attach it to a body. The hull is cloned then transformed with scale applied first. Use this for non-uniform or mirrored scale or a baked local transform. The baked result is shared through the world hull database. 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 b3CreateTransformedHullShape.
Create a mesh hull shape and attach it to a body. The shape definition is fully cloned but the mesh is not. Contacts are not created until the next time step. Mesh collision only creates contacts on static bodies. Warning: this holds reference to the input mesh data which must remain valid for the lifetime of this shape
Returns: the shape id for accessing the shape
Binds b3CreateMeshShape.
createHeightField :: BodyId -> ShapeDef -> Ptr HeightFieldData -> IO ShapeId Source #
Create a height-field shape and attach it to a body. The shape definition is fully cloned but the height field is not. Contacts are not created until the next time step. Height field is only allowed on static bodies. Warning: this holds reference to the input height field which must remain valid for the lifetime of this shape
Returns: the shape id for accessing the shape
Binds b3CreateHeightFieldShape.
createCompound :: BodyId -> Ptr ShapeDef -> Ptr CompoundData -> IO ShapeId Source #
Compound shapes are only allowed on static bodies.
Binds b3CreateCompoundShape.
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 b3Body_ApplyMassFromShapes.
Binds b3DestroyShape.
isValid :: ShapeId -> IO Bool Source #
Shape identifier validation. Provides validation for up to 64K allocations.
Binds b3Shape_IsValid.
getBody :: ShapeId -> IO BodyId Source #
Get the id of the body that a shape is attached to
Binds b3Shape_GetBody.
Set the user data for a shape
Binds b3Shape_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 b3Shape_GetUserData.
Set the mass density of a shape, usually in kg/m^3. This will optionally update the mass properties on the parent body. See also b3ShapeDef::density, b3Body_ApplyMassFromShapes.
Binds b3Shape_SetDensity.
getDensity :: ShapeId -> IO Float Source #
Get the density of a shape, usually in kg/m^3
Binds b3Shape_GetDensity.
Set the friction on a shape
Binds b3Shape_SetFriction.
Set the shape restitution (bounciness)
Binds b3Shape_SetRestitution.
getRestitution :: ShapeId -> IO Float Source #
Get the shape restitution
Binds b3Shape_GetRestitution.
setSurfaceMaterial :: ShapeId -> SurfaceMaterial -> IO () Source #
Set the shape base surface material. Does not change per triangle materials.
Binds b3Shape_SetSurfaceMaterial.
getSurfaceMaterial :: ShapeId -> IO SurfaceMaterial Source #
Get the base shape surface material.
Binds b3Shape_GetSurfaceMaterial.
getSurfaceMaterialInto Source #
Arguments
| :: ShapeId | |
| -> Ptr SurfaceMaterial | Result buffer. |
| -> IO () |
Like getSurfaceMaterial, but the result is written into a caller-supplied buffer.
getMeshMaterialCount :: ShapeId -> IO Int Source #
Get the number of mesh surface materials.
Binds b3Shape_GetMeshMaterialCount.
Arguments
| :: ShapeId | |
| -> SurfaceMaterial | |
| -> Int | index |
| -> IO () |
Set a surface material for a mesh shape.
Binds b3Shape_SetMeshMaterial.
getMeshSurfaceMaterial Source #
Arguments
| :: ShapeId | |
| -> Int | index |
| -> IO SurfaceMaterial |
Get a surface material for a mesh shape
Binds b3Shape_GetMeshSurfaceMaterial.
getMeshSurfaceMaterialInto Source #
Arguments
| :: ShapeId | |
| -> Int | index |
| -> Ptr SurfaceMaterial | Result buffer. |
| -> IO () |
Like getMeshSurfaceMaterial, but the result is written into a caller-supplied buffer.
Like getFilter, but the result is written into a caller-supplied buffer.
Arguments
| :: ShapeId |
|
| -> Filter |
|
| -> Bool |
|
| -> IO () |
Set the current filter. This is almost as expensive as recreating the shape. See also b3ShapeDef::filter.
Binds b3Shape_SetFilter.
Enable sensor events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. See also b3ShapeDef::isSensor.
Binds b3Shape_EnableSensorEvents.
areSensorEventsEnabled :: ShapeId -> IO Bool Source #
Returns true if sensor events are enabled
Binds b3Shape_AreSensorEventsEnabled.
Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. See also b3ShapeDef::enableContactEvents.
Binds b3Shape_EnableContactEvents.
areContactEventsEnabled :: ShapeId -> IO Bool Source #
Returns true if contact events are enabled
Binds b3Shape_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 b3PreSolveFcn.
Binds b3Shape_EnablePreSolveEvents.
arePreSolveEventsEnabled :: ShapeId -> IO Bool Source #
Returns true if pre-solve events are enabled
Binds b3Shape_ArePreSolveEventsEnabled.
Enable contact hit events for this shape. Ignored for sensors. See also b3WorldDef.hitEventThreshold.
Binds b3Shape_EnableHitEvents.
areHitEventsEnabled :: ShapeId -> IO Bool Source #
Returns true if hit events are enabled
Binds b3Shape_AreHitEventsEnabled.
Arguments
| :: ShapeId | |
| -> Pos | origin |
| -> Vec3 | translation |
| -> IO WorldCastOutput |
Ray cast a shape directly. The ray runs from origin to origin + translation and the hit point comes back as a world position, so the cast stays precise far from the world origin.
Binds b3Shape_RayCast.
getSphere :: ShapeId -> IO Sphere Source #
Get a copy of the shape's sphere. Asserts the type is correct.
Binds b3Shape_GetSphere.
Like getSphere, but the result is written into a caller-supplied buffer.
getCapsule :: ShapeId -> IO Capsule Source #
Get a copy of the shape's capsule. Asserts the type is correct.
Binds b3Shape_GetCapsule.
Like getCapsule, but the result is written into a caller-supplied buffer.
getHull :: ShapeId -> IO (Ptr HullData) Source #
Get the shape's convex hull. Asserts the type is correct.
Binds b3Shape_GetHull.
Get the shape's mesh. Asserts the type is correct.
Binds b3Shape_GetMesh.
getHeightField :: ShapeId -> IO (Ptr HeightFieldData) Source #
Get the shape's height field. Asserts the type is correct.
Binds b3Shape_GetHeightField.
setSphere :: ShapeId -> Sphere -> IO () Source #
Allows you to change a shape to be a sphere or update the current sphere. This does not modify the mass properties. See also b3Body_ApplyMassFromShapes.
Binds b3Shape_SetSphere.
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 b3Body_ApplyMassFromShapes.
Binds b3Shape_SetCapsule.
setHull :: ShapeId -> Ptr HullData -> IO () Source #
Allows you to change a shape to be a hull or update the current hull. This does not modify the mass properties. See also b3Body_ApplyMassFromShapes.
Binds b3Shape_SetHull.
Allows you to change a shape to be a mesh or update the current mesh. This does not modify the mass properties. See also b3Body_ApplyMassFromShapes.
Binds b3Shape_SetMesh.
getContactCapacity :: ShapeId -> IO Int Source #
Get the maximum capacity required for retrieving all the touching contacts on a shape
Binds b3Shape_GetContactCapacity.
Get the touching contact data for a shape. The provided shapeId will be either shapeIdA or shapeIdB on the contact data. Note: Box3D 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 b3Shape_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 b3Shape_GetSensorOverlaps
Binds b3Shape_GetSensorCapacity.
Arguments
| :: ShapeId |
|
| -> Ptr ShapeId |
|
| -> Int |
|
| -> IO Int |
Get the overlap data for a sensor shape. Warning: do not ignore the return value, it specifies the valid number of elements Warning: overlaps may contain destroyed shapes so use b3Shape_IsValid to confirm each overlap
Returns: the number of elements filled in the provided array
Binds b3Shape_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 b3Shape_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 in world space.
Binds b3Shape_GetClosestPoint.
Arguments
| :: ShapeId |
|
| -> Vec3 |
|
| -> Float |
|
| -> 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 b3Shape_ApplyWind.