-- Produced by boxnd-gen; edit the generator, not this file.

module Box3D.Shape
  ( createSphere
  , createCapsule
  , createHull
  , createTransformedHull
  , createMesh
  , createHeightField
  , createCompound
  , destroy
  , isValid
  , getType
  , getBody
  , getWorld
  , isSensor
  , setUserData
  , getUserData
  , setDensity
  , getDensity
  , setFriction
  , getFriction
  , setRestitution
  , getRestitution
  , setSurfaceMaterial
  , getSurfaceMaterial
  , getSurfaceMaterialInto
  , getMeshMaterialCount
  , setMeshMaterial
  , getMeshSurfaceMaterial
  , getMeshSurfaceMaterialInto
  , getFilter
  , getFilterInto
  , setFilter
  , enableSensorEvents
  , areSensorEventsEnabled
  , enableContactEvents
  , areContactEventsEnabled
  , enablePreSolveEvents
  , arePreSolveEventsEnabled
  , enableHitEvents
  , areHitEventsEnabled
  , rayCast
  , getSphere
  , getSphereInto
  , getCapsule
  , getCapsuleInto
  , getHull
  , getMesh
  , getHeightField
  , setSphere
  , setCapsule
  , setHull
  , setMesh
  , getContactCapacity
  , getContactData
  , getSensorCapacity
  , getSensorData
  , getAABB
  , getAABBInto
  , computeMassData
  , computeMassDataInto
  , getClosestPoint
  , applyWind
  )

  where

import Foreign
import Foreign.C.Types (CBool(..), CInt(..))
import Data.Coerce (coerce)
import Box3D.Id (BodyId(..), ShapeId(..), WorldId(..))
import Box3D.MathTypes (AABB, Pos, Transform, Vec3)
import Box3D.Tags (CompoundData, ContactData, HeightFieldData, HullData, Mesh, MeshData)
import Box3D.Types (Capsule, Filter, MassData, ShapeDef, ShapeType(..), Sphere, SurfaceMaterial, WorldCastOutput)

foreign import ccall unsafe "b3CreateSphereShape"
  c_b3CreateSphereShape :: BodyId -> Ptr ShapeDef -> Ptr Sphere -> IO ShapeId

foreign import ccall unsafe "b3CreateCapsuleShape"
  c_b3CreateCapsuleShape :: BodyId -> Ptr ShapeDef -> Ptr Capsule -> IO ShapeId

foreign import ccall unsafe "b3CreateHullShape"
  c_b3CreateHullShape :: BodyId -> Ptr ShapeDef -> Ptr HullData -> IO ShapeId

foreign import ccall unsafe "hsg_b3CreateTransformedHullShape"
  c_b3CreateTransformedHullShape :: BodyId -> Ptr ShapeDef -> Ptr HullData -> Ptr Transform -> Ptr Vec3 -> IO ShapeId

foreign import ccall unsafe "hsg_b3CreateMeshShape"
  c_b3CreateMeshShape :: BodyId -> Ptr ShapeDef -> Ptr MeshData -> Ptr Vec3 -> IO ShapeId

foreign import ccall unsafe "b3CreateHeightFieldShape"
  c_b3CreateHeightFieldShape :: BodyId -> Ptr ShapeDef -> Ptr HeightFieldData -> IO ShapeId

foreign import ccall unsafe "b3CreateCompoundShape"
  c_b3CreateCompoundShape :: BodyId -> Ptr ShapeDef -> Ptr CompoundData -> IO ShapeId

foreign import ccall unsafe "b3DestroyShape"
  c_b3DestroyShape :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b3Shape_IsValid"
  c_b3Shape_IsValid :: ShapeId -> IO CBool

foreign import ccall unsafe "b3Shape_GetType"
  c_b3Shape_GetType :: ShapeId -> IO CInt

foreign import ccall unsafe "b3Shape_GetBody"
  c_b3Shape_GetBody :: ShapeId -> IO BodyId

foreign import ccall unsafe "b3Shape_GetWorld"
  c_b3Shape_GetWorld :: ShapeId -> IO WorldId

foreign import ccall unsafe "b3Shape_IsSensor"
  c_b3Shape_IsSensor :: ShapeId -> IO CBool

foreign import ccall unsafe "b3Shape_SetUserData"
  c_b3Shape_SetUserData :: ShapeId -> Ptr () -> IO ()

foreign import ccall unsafe "b3Shape_GetUserData"
  c_b3Shape_GetUserData :: ShapeId -> IO (Ptr ())

foreign import ccall unsafe "b3Shape_SetDensity"
  c_b3Shape_SetDensity :: ShapeId -> Float -> CBool -> IO ()

foreign import ccall unsafe "b3Shape_GetDensity"
  c_b3Shape_GetDensity :: ShapeId -> IO Float

foreign import ccall unsafe "b3Shape_SetFriction"
  c_b3Shape_SetFriction :: ShapeId -> Float -> IO ()

foreign import ccall unsafe "b3Shape_GetFriction"
  c_b3Shape_GetFriction :: ShapeId -> IO Float

foreign import ccall unsafe "b3Shape_SetRestitution"
  c_b3Shape_SetRestitution :: ShapeId -> Float -> IO ()

foreign import ccall unsafe "b3Shape_GetRestitution"
  c_b3Shape_GetRestitution :: ShapeId -> IO Float

foreign import ccall unsafe "hsg_b3Shape_SetSurfaceMaterial"
  c_b3Shape_SetSurfaceMaterial :: ShapeId -> Ptr SurfaceMaterial -> IO ()

foreign import ccall unsafe "hsg_b3Shape_GetSurfaceMaterial"
  c_b3Shape_GetSurfaceMaterial :: ShapeId -> Ptr SurfaceMaterial -> IO ()

foreign import ccall unsafe "b3Shape_GetMeshMaterialCount"
  c_b3Shape_GetMeshMaterialCount :: ShapeId -> IO CInt

foreign import ccall unsafe "hsg_b3Shape_SetMeshMaterial"
  c_b3Shape_SetMeshMaterial :: ShapeId -> Ptr SurfaceMaterial -> CInt -> IO ()

foreign import ccall unsafe "hsg_b3Shape_GetMeshSurfaceMaterial"
  c_b3Shape_GetMeshSurfaceMaterial :: ShapeId -> CInt -> Ptr SurfaceMaterial -> IO ()

foreign import ccall unsafe "hsg_b3Shape_GetFilter"
  c_b3Shape_GetFilter :: ShapeId -> Ptr Filter -> IO ()

foreign import ccall unsafe "hsg_b3Shape_SetFilter"
  c_b3Shape_SetFilter :: ShapeId -> Ptr Filter -> CBool -> IO ()

foreign import ccall unsafe "b3Shape_EnableSensorEvents"
  c_b3Shape_EnableSensorEvents :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b3Shape_AreSensorEventsEnabled"
  c_b3Shape_AreSensorEventsEnabled :: ShapeId -> IO CBool

foreign import ccall unsafe "b3Shape_EnableContactEvents"
  c_b3Shape_EnableContactEvents :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b3Shape_AreContactEventsEnabled"
  c_b3Shape_AreContactEventsEnabled :: ShapeId -> IO CBool

foreign import ccall unsafe "b3Shape_EnablePreSolveEvents"
  c_b3Shape_EnablePreSolveEvents :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b3Shape_ArePreSolveEventsEnabled"
  c_b3Shape_ArePreSolveEventsEnabled :: ShapeId -> IO CBool

foreign import ccall unsafe "b3Shape_EnableHitEvents"
  c_b3Shape_EnableHitEvents :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b3Shape_AreHitEventsEnabled"
  c_b3Shape_AreHitEventsEnabled :: ShapeId -> IO CBool

foreign import ccall unsafe "hsg_b3Shape_RayCast"
  c_b3Shape_RayCast :: ShapeId -> Ptr Pos -> Ptr Vec3 -> Ptr WorldCastOutput -> IO ()

foreign import ccall unsafe "hsg_b3Shape_GetSphere"
  c_b3Shape_GetSphere :: ShapeId -> Ptr Sphere -> IO ()

foreign import ccall unsafe "hsg_b3Shape_GetCapsule"
  c_b3Shape_GetCapsule :: ShapeId -> Ptr Capsule -> IO ()

foreign import ccall unsafe "b3Shape_GetHull"
  c_b3Shape_GetHull :: ShapeId -> IO (Ptr HullData)

foreign import ccall unsafe "hsg_b3Shape_GetMesh"
  c_b3Shape_GetMesh :: ShapeId -> Ptr Mesh -> IO ()

foreign import ccall unsafe "b3Shape_GetHeightField"
  c_b3Shape_GetHeightField :: ShapeId -> IO (Ptr HeightFieldData)

foreign import ccall unsafe "b3Shape_SetSphere"
  c_b3Shape_SetSphere :: ShapeId -> Ptr Sphere -> IO ()

foreign import ccall unsafe "b3Shape_SetCapsule"
  c_b3Shape_SetCapsule :: ShapeId -> Ptr Capsule -> IO ()

foreign import ccall unsafe "b3Shape_SetHull"
  c_b3Shape_SetHull :: ShapeId -> Ptr HullData -> IO ()

foreign import ccall unsafe "hsg_b3Shape_SetMesh"
  c_b3Shape_SetMesh :: ShapeId -> Ptr MeshData -> Ptr Vec3 -> IO ()

foreign import ccall unsafe "b3Shape_GetContactCapacity"
  c_b3Shape_GetContactCapacity :: ShapeId -> IO CInt

foreign import ccall unsafe "b3Shape_GetContactData"
  c_b3Shape_GetContactData :: ShapeId -> Ptr ContactData -> CInt -> IO CInt

foreign import ccall unsafe "b3Shape_GetSensorCapacity"
  c_b3Shape_GetSensorCapacity :: ShapeId -> IO CInt

foreign import ccall unsafe "b3Shape_GetSensorData"
  c_b3Shape_GetSensorData :: ShapeId -> Ptr ShapeId -> CInt -> IO CInt

foreign import ccall unsafe "hsg_b3Shape_GetAABB"
  c_b3Shape_GetAABB :: ShapeId -> Ptr AABB -> IO ()

foreign import ccall unsafe "hsg_b3Shape_ComputeMassData"
  c_b3Shape_ComputeMassData :: ShapeId -> Ptr MassData -> IO ()

foreign import ccall unsafe "hsg_b3Shape_GetClosestPoint"
  c_b3Shape_GetClosestPoint :: ShapeId -> Ptr Vec3 -> Ptr Vec3 -> IO ()

foreign import ccall unsafe "hsg_b3Shape_ApplyWind"
  c_b3Shape_ApplyWind :: ShapeId -> Ptr Vec3 -> Float -> Float -> Float -> CBool -> IO ()

{- | 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@.
-}
createSphere
  :: BodyId
  -> ShapeDef
  -> Sphere
  -> IO ShapeId
createSphere :: BodyId -> ShapeDef -> Sphere -> IO ShapeId
createSphere BodyId
a0 ShapeDef
a1 Sphere
a2 =
  ShapeDef -> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with ShapeDef
a1 ((Ptr ShapeDef -> IO ShapeId) -> IO ShapeId)
-> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr ShapeDef
p1 ->
  Sphere -> (Ptr Sphere -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Sphere
a2 ((Ptr Sphere -> IO ShapeId) -> IO ShapeId)
-> (Ptr Sphere -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr Sphere
p2 ->
  BodyId -> Ptr ShapeDef -> Ptr Sphere -> IO ShapeId
c_b3CreateSphereShape BodyId
a0 Ptr ShapeDef
p1 Ptr Sphere
p2

{- | 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@.
-}
createCapsule
  :: BodyId
  -> ShapeDef
  -> Capsule
  -> IO ShapeId
createCapsule :: BodyId -> ShapeDef -> Capsule -> IO ShapeId
createCapsule BodyId
a0 ShapeDef
a1 Capsule
a2 =
  ShapeDef -> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with ShapeDef
a1 ((Ptr ShapeDef -> IO ShapeId) -> IO ShapeId)
-> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr ShapeDef
p1 ->
  Capsule -> (Ptr Capsule -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Capsule
a2 ((Ptr Capsule -> IO ShapeId) -> IO ShapeId)
-> (Ptr Capsule -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr Capsule
p2 ->
  BodyId -> Ptr ShapeDef -> Ptr Capsule -> IO ShapeId
c_b3CreateCapsuleShape BodyId
a0 Ptr ShapeDef
p1 Ptr Capsule
p2

{- | 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@.
-}
createHull
  :: BodyId
  -> ShapeDef
  -> Ptr HullData
  -> IO ShapeId
createHull :: BodyId -> ShapeDef -> Ptr HullData -> IO ShapeId
createHull BodyId
a0 ShapeDef
a1 Ptr HullData
a2 =
  ShapeDef -> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with ShapeDef
a1 ((Ptr ShapeDef -> IO ShapeId) -> IO ShapeId)
-> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr ShapeDef
p1 ->
  BodyId -> Ptr ShapeDef -> Ptr HullData -> IO ShapeId
c_b3CreateHullShape BodyId
a0 Ptr ShapeDef
p1 Ptr HullData
a2

{- | 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@.
-}
createTransformedHull
  :: BodyId
  -> ShapeDef
  -> Ptr HullData
  -> Transform
  -> Vec3
  -- ^ @scale@
  -> IO ShapeId
createTransformedHull :: BodyId
-> ShapeDef -> Ptr HullData -> Transform -> Vec3 -> IO ShapeId
createTransformedHull BodyId
a0 ShapeDef
a1 Ptr HullData
a2 Transform
a3 Vec3
a4 =
  ShapeDef -> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with ShapeDef
a1 ((Ptr ShapeDef -> IO ShapeId) -> IO ShapeId)
-> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr ShapeDef
p1 ->
  Transform -> (Ptr Transform -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Transform
a3 ((Ptr Transform -> IO ShapeId) -> IO ShapeId)
-> (Ptr Transform -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr Transform
p3 ->
  Vec3 -> (Ptr Vec3 -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec3
a4 ((Ptr Vec3 -> IO ShapeId) -> IO ShapeId)
-> (Ptr Vec3 -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
p4 ->
  BodyId
-> Ptr ShapeDef
-> Ptr HullData
-> Ptr Transform
-> Ptr Vec3
-> IO ShapeId
c_b3CreateTransformedHullShape BodyId
a0 Ptr ShapeDef
p1 Ptr HullData
a2 Ptr Transform
p3 Ptr Vec3
p4

{- | 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@.
-}
createMesh
  :: BodyId
  -> ShapeDef
  -> Ptr MeshData
  -> Vec3
  -- ^ @scale@
  -> IO ShapeId
createMesh :: BodyId -> ShapeDef -> Ptr MeshData -> Vec3 -> IO ShapeId
createMesh BodyId
a0 ShapeDef
a1 Ptr MeshData
a2 Vec3
a3 =
  ShapeDef -> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with ShapeDef
a1 ((Ptr ShapeDef -> IO ShapeId) -> IO ShapeId)
-> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr ShapeDef
p1 ->
  Vec3 -> (Ptr Vec3 -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec3
a3 ((Ptr Vec3 -> IO ShapeId) -> IO ShapeId)
-> (Ptr Vec3 -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
p3 ->
  BodyId -> Ptr ShapeDef -> Ptr MeshData -> Ptr Vec3 -> IO ShapeId
c_b3CreateMeshShape BodyId
a0 Ptr ShapeDef
p1 Ptr MeshData
a2 Ptr Vec3
p3

{- | 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@.
-}
createHeightField
  :: BodyId
  -> ShapeDef
  -> Ptr HeightFieldData
  -> IO ShapeId
createHeightField :: BodyId -> ShapeDef -> Ptr HeightFieldData -> IO ShapeId
createHeightField BodyId
a0 ShapeDef
a1 Ptr HeightFieldData
a2 =
  ShapeDef -> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with ShapeDef
a1 ((Ptr ShapeDef -> IO ShapeId) -> IO ShapeId)
-> (Ptr ShapeDef -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr ShapeDef
p1 ->
  BodyId -> Ptr ShapeDef -> Ptr HeightFieldData -> IO ShapeId
c_b3CreateHeightFieldShape BodyId
a0 Ptr ShapeDef
p1 Ptr HeightFieldData
a2

{- | Compound shapes are only allowed on static bodies.

Binds @b3CreateCompoundShape@.
-}
createCompound
  :: BodyId
  -> Ptr ShapeDef
  -> Ptr CompoundData
  -> IO ShapeId
createCompound :: BodyId -> Ptr ShapeDef -> Ptr CompoundData -> IO ShapeId
createCompound BodyId
a0 Ptr ShapeDef
a1 Ptr CompoundData
a2 =
  BodyId -> Ptr ShapeDef -> Ptr CompoundData -> IO ShapeId
c_b3CreateCompoundShape BodyId
a0 Ptr ShapeDef
a1 Ptr CompoundData
a2

{- | 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@.
-}
destroy
  :: ShapeId
  -> Bool
  -- ^ @updateBodyMass@
  -> IO ()
destroy :: ShapeId -> Bool -> IO ()
destroy ShapeId
a0 Bool
a1 =
  ShapeId -> CBool -> IO ()
c_b3DestroyShape ShapeId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Shape identifier validation. Provides validation for up to 64K allocations.

Binds @b3Shape_IsValid@.
-}
isValid
  :: ShapeId
  -> IO Bool
isValid :: ShapeId -> IO Bool
isValid ShapeId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CBool
c_b3Shape_IsValid ShapeId
a0)

{- | Get the type of a shape

Binds @b3Shape_GetType@.
-}
getType
  :: ShapeId
  -> IO ShapeType
getType :: ShapeId -> IO ShapeType
getType ShapeId
a0 =
  CInt -> ShapeType
forall a b. Coercible a b => a -> b
coerce (CInt -> ShapeType) -> IO CInt -> IO ShapeType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CInt
c_b3Shape_GetType ShapeId
a0)

{- | Get the id of the body that a shape is attached to

Binds @b3Shape_GetBody@.
-}
getBody
  :: ShapeId
  -> IO BodyId
getBody :: ShapeId -> IO BodyId
getBody ShapeId
a0 =
  ShapeId -> IO BodyId
c_b3Shape_GetBody ShapeId
a0

{- | Get the world that owns this shape

Binds @b3Shape_GetWorld@.
-}
getWorld
  :: ShapeId
  -> IO WorldId
getWorld :: ShapeId -> IO WorldId
getWorld ShapeId
a0 =
  ShapeId -> IO WorldId
c_b3Shape_GetWorld ShapeId
a0

{- | Returns true if the shape is a sensor

Binds @b3Shape_IsSensor@.
-}
isSensor
  :: ShapeId
  -> IO Bool
isSensor :: ShapeId -> IO Bool
isSensor ShapeId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CBool
c_b3Shape_IsSensor ShapeId
a0)

{- | Set the user data for a shape

Binds @b3Shape_SetUserData@.
-}
setUserData
  :: ShapeId
  -> Ptr ()
  -- ^ @userData@
  -> IO ()
setUserData :: ShapeId -> Ptr () -> IO ()
setUserData ShapeId
a0 Ptr ()
a1 =
  ShapeId -> Ptr () -> IO ()
c_b3Shape_SetUserData ShapeId
a0 Ptr ()
a1

{- | Get the user data for a shape. This is useful when you get a shape id
from an event or query.

Binds @b3Shape_GetUserData@.
-}
getUserData
  :: ShapeId
  -> IO (Ptr ())
getUserData :: ShapeId -> IO (Ptr ())
getUserData ShapeId
a0 =
  ShapeId -> IO (Ptr ())
c_b3Shape_GetUserData ShapeId
a0

{- | 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@.
-}
setDensity
  :: ShapeId
  -> Float
  -- ^ @density@
  -> Bool
  -- ^ @updateBodyMass@
  -> IO ()
setDensity :: ShapeId -> Float -> Bool -> IO ()
setDensity ShapeId
a0 Float
a1 Bool
a2 =
  ShapeId -> Float -> CBool -> IO ()
c_b3Shape_SetDensity ShapeId
a0 Float
a1 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a2)

{- | Get the density of a shape, usually in kg\/m^3

Binds @b3Shape_GetDensity@.
-}
getDensity
  :: ShapeId
  -> IO Float
getDensity :: ShapeId -> IO Float
getDensity ShapeId
a0 =
  ShapeId -> IO Float
c_b3Shape_GetDensity ShapeId
a0

{- | Set the friction on a shape

Binds @b3Shape_SetFriction@.
-}
setFriction
  :: ShapeId
  -> Float
  -- ^ @friction@
  -> IO ()
setFriction :: ShapeId -> Float -> IO ()
setFriction ShapeId
a0 Float
a1 =
  ShapeId -> Float -> IO ()
c_b3Shape_SetFriction ShapeId
a0 Float
a1

{- | Get the friction of a shape

Binds @b3Shape_GetFriction@.
-}
getFriction
  :: ShapeId
  -> IO Float
getFriction :: ShapeId -> IO Float
getFriction ShapeId
a0 =
  ShapeId -> IO Float
c_b3Shape_GetFriction ShapeId
a0

{- | Set the shape restitution (bounciness)

Binds @b3Shape_SetRestitution@.
-}
setRestitution
  :: ShapeId
  -> Float
  -- ^ @restitution@
  -> IO ()
setRestitution :: ShapeId -> Float -> IO ()
setRestitution ShapeId
a0 Float
a1 =
  ShapeId -> Float -> IO ()
c_b3Shape_SetRestitution ShapeId
a0 Float
a1

{- | Get the shape restitution

Binds @b3Shape_GetRestitution@.
-}
getRestitution
  :: ShapeId
  -> IO Float
getRestitution :: ShapeId -> IO Float
getRestitution ShapeId
a0 =
  ShapeId -> IO Float
c_b3Shape_GetRestitution ShapeId
a0

{- | Set the shape base surface material. Does not change per triangle materials.

Binds @b3Shape_SetSurfaceMaterial@.
-}
setSurfaceMaterial
  :: ShapeId
  -> SurfaceMaterial
  -> IO ()
setSurfaceMaterial :: ShapeId -> SurfaceMaterial -> IO ()
setSurfaceMaterial ShapeId
a0 SurfaceMaterial
a1 =
  SurfaceMaterial -> (Ptr SurfaceMaterial -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with SurfaceMaterial
a1 ((Ptr SurfaceMaterial -> IO ()) -> IO ())
-> (Ptr SurfaceMaterial -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr SurfaceMaterial
p1 ->
  ShapeId -> Ptr SurfaceMaterial -> IO ()
c_b3Shape_SetSurfaceMaterial ShapeId
a0 Ptr SurfaceMaterial
p1

{- | Get the base shape surface material.

Binds @b3Shape_GetSurfaceMaterial@.
-}
getSurfaceMaterial
  :: ShapeId
  -> IO SurfaceMaterial
getSurfaceMaterial :: ShapeId -> IO SurfaceMaterial
getSurfaceMaterial ShapeId
a0 =
  (Ptr SurfaceMaterial -> IO SurfaceMaterial) -> IO SurfaceMaterial
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr SurfaceMaterial -> IO SurfaceMaterial) -> IO SurfaceMaterial)
-> (Ptr SurfaceMaterial -> IO SurfaceMaterial)
-> IO SurfaceMaterial
forall a b. (a -> b) -> a -> b
$ \Ptr SurfaceMaterial
pOut -> ShapeId -> Ptr SurfaceMaterial -> IO ()
c_b3Shape_GetSurfaceMaterial ShapeId
a0 Ptr SurfaceMaterial
pOut IO () -> IO SurfaceMaterial -> IO SurfaceMaterial
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr SurfaceMaterial -> IO SurfaceMaterial
forall a. Storable a => Ptr a -> IO a
peek Ptr SurfaceMaterial
pOut

-- | Like 'getSurfaceMaterial', but the result is written into a caller-supplied buffer.
getSurfaceMaterialInto
  :: ShapeId
  -> Ptr SurfaceMaterial
  -- ^ Result buffer.
  -> IO ()
getSurfaceMaterialInto :: ShapeId -> Ptr SurfaceMaterial -> IO ()
getSurfaceMaterialInto ShapeId
a0 Ptr SurfaceMaterial
out =
  ShapeId -> Ptr SurfaceMaterial -> IO ()
c_b3Shape_GetSurfaceMaterial ShapeId
a0 Ptr SurfaceMaterial
out

{- | Get the number of mesh surface materials.

Binds @b3Shape_GetMeshMaterialCount@.
-}
getMeshMaterialCount
  :: ShapeId
  -> IO Int
getMeshMaterialCount :: ShapeId -> IO Int
getMeshMaterialCount ShapeId
a0 =
  CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CInt -> Int) -> IO CInt -> IO Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CInt
c_b3Shape_GetMeshMaterialCount ShapeId
a0)

{- | Set a surface material for a mesh shape.

Binds @b3Shape_SetMeshMaterial@.
-}
setMeshMaterial
  :: ShapeId
  -> SurfaceMaterial
  -> Int
  -- ^ @index@
  -> IO ()
setMeshMaterial :: ShapeId -> SurfaceMaterial -> Int -> IO ()
setMeshMaterial ShapeId
a0 SurfaceMaterial
a1 Int
a2 =
  SurfaceMaterial -> (Ptr SurfaceMaterial -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with SurfaceMaterial
a1 ((Ptr SurfaceMaterial -> IO ()) -> IO ())
-> (Ptr SurfaceMaterial -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr SurfaceMaterial
p1 ->
  ShapeId -> Ptr SurfaceMaterial -> CInt -> IO ()
c_b3Shape_SetMeshMaterial ShapeId
a0 Ptr SurfaceMaterial
p1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2)

{- | Get a surface material for a mesh shape

Binds @b3Shape_GetMeshSurfaceMaterial@.
-}
getMeshSurfaceMaterial
  :: ShapeId
  -> Int
  -- ^ @index@
  -> IO SurfaceMaterial
getMeshSurfaceMaterial :: ShapeId -> Int -> IO SurfaceMaterial
getMeshSurfaceMaterial ShapeId
a0 Int
a1 =
  (Ptr SurfaceMaterial -> IO SurfaceMaterial) -> IO SurfaceMaterial
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr SurfaceMaterial -> IO SurfaceMaterial) -> IO SurfaceMaterial)
-> (Ptr SurfaceMaterial -> IO SurfaceMaterial)
-> IO SurfaceMaterial
forall a b. (a -> b) -> a -> b
$ \Ptr SurfaceMaterial
pOut -> ShapeId -> CInt -> Ptr SurfaceMaterial -> IO ()
c_b3Shape_GetMeshSurfaceMaterial ShapeId
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1) Ptr SurfaceMaterial
pOut IO () -> IO SurfaceMaterial -> IO SurfaceMaterial
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr SurfaceMaterial -> IO SurfaceMaterial
forall a. Storable a => Ptr a -> IO a
peek Ptr SurfaceMaterial
pOut

-- | Like 'getMeshSurfaceMaterial', but the result is written into a caller-supplied buffer.
getMeshSurfaceMaterialInto
  :: ShapeId
  -> Int
  -- ^ @index@
  -> Ptr SurfaceMaterial
  -- ^ Result buffer.
  -> IO ()
getMeshSurfaceMaterialInto :: ShapeId -> Int -> Ptr SurfaceMaterial -> IO ()
getMeshSurfaceMaterialInto ShapeId
a0 Int
a1 Ptr SurfaceMaterial
out =
  ShapeId -> CInt -> Ptr SurfaceMaterial -> IO ()
c_b3Shape_GetMeshSurfaceMaterial ShapeId
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1) Ptr SurfaceMaterial
out

{- | Get the shape filter

Binds @b3Shape_GetFilter@.
-}
getFilter
  :: ShapeId
  -> IO Filter
getFilter :: ShapeId -> IO Filter
getFilter ShapeId
a0 =
  (Ptr Filter -> IO Filter) -> IO Filter
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Filter -> IO Filter) -> IO Filter)
-> (Ptr Filter -> IO Filter) -> IO Filter
forall a b. (a -> b) -> a -> b
$ \Ptr Filter
pOut -> ShapeId -> Ptr Filter -> IO ()
c_b3Shape_GetFilter ShapeId
a0 Ptr Filter
pOut IO () -> IO Filter -> IO Filter
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Filter -> IO Filter
forall a. Storable a => Ptr a -> IO a
peek Ptr Filter
pOut

-- | Like 'getFilter', but the result is written into a caller-supplied buffer.
getFilterInto
  :: ShapeId
  -> Ptr Filter
  -- ^ Result buffer.
  -> IO ()
getFilterInto :: ShapeId -> Ptr Filter -> IO ()
getFilterInto ShapeId
a0 Ptr Filter
out =
  ShapeId -> Ptr Filter -> IO ()
c_b3Shape_GetFilter ShapeId
a0 Ptr Filter
out

{- | Set the current filter. This is almost as expensive as recreating the shape.
See also b3ShapeDef::filter.

Binds @b3Shape_SetFilter@.
-}
setFilter
  :: ShapeId
  -- ^ @shapeId@: the shape
  -> Filter
  -- ^ @filter@: the new filter
  -> Bool
  -- ^ @invokeContacts@: if true then the shape will have all contacts recomputed the next time step (expensive)
  -> IO ()
setFilter :: ShapeId -> Filter -> Bool -> IO ()
setFilter ShapeId
a0 Filter
a1 Bool
a2 =
  Filter -> (Ptr Filter -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Filter
a1 ((Ptr Filter -> IO ()) -> IO ()) -> (Ptr Filter -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Filter
p1 ->
  ShapeId -> Ptr Filter -> CBool -> IO ()
c_b3Shape_SetFilter ShapeId
a0 Ptr Filter
p1 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a2)

{- | Enable sensor events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors.
See also b3ShapeDef::isSensor.

Binds @b3Shape_EnableSensorEvents@.
-}
enableSensorEvents
  :: ShapeId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableSensorEvents :: ShapeId -> Bool -> IO ()
enableSensorEvents ShapeId
a0 Bool
a1 =
  ShapeId -> CBool -> IO ()
c_b3Shape_EnableSensorEvents ShapeId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Returns true if sensor events are enabled

Binds @b3Shape_AreSensorEventsEnabled@.
-}
areSensorEventsEnabled
  :: ShapeId
  -> IO Bool
areSensorEventsEnabled :: ShapeId -> IO Bool
areSensorEventsEnabled ShapeId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CBool
c_b3Shape_AreSensorEventsEnabled ShapeId
a0)

{- | Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors.
See also b3ShapeDef::enableContactEvents.

Binds @b3Shape_EnableContactEvents@.
-}
enableContactEvents
  :: ShapeId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableContactEvents :: ShapeId -> Bool -> IO ()
enableContactEvents ShapeId
a0 Bool
a1 =
  ShapeId -> CBool -> IO ()
c_b3Shape_EnableContactEvents ShapeId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Returns true if contact events are enabled

Binds @b3Shape_AreContactEventsEnabled@.
-}
areContactEventsEnabled
  :: ShapeId
  -> IO Bool
areContactEventsEnabled :: ShapeId -> IO Bool
areContactEventsEnabled ShapeId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CBool
c_b3Shape_AreContactEventsEnabled ShapeId
a0)

{- | 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@.
-}
enablePreSolveEvents
  :: ShapeId
  -> Bool
  -- ^ @flag@
  -> IO ()
enablePreSolveEvents :: ShapeId -> Bool -> IO ()
enablePreSolveEvents ShapeId
a0 Bool
a1 =
  ShapeId -> CBool -> IO ()
c_b3Shape_EnablePreSolveEvents ShapeId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Returns true if pre-solve events are enabled

Binds @b3Shape_ArePreSolveEventsEnabled@.
-}
arePreSolveEventsEnabled
  :: ShapeId
  -> IO Bool
arePreSolveEventsEnabled :: ShapeId -> IO Bool
arePreSolveEventsEnabled ShapeId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CBool
c_b3Shape_ArePreSolveEventsEnabled ShapeId
a0)

{- | Enable contact hit events for this shape. Ignored for sensors.
See also b3WorldDef.hitEventThreshold.

Binds @b3Shape_EnableHitEvents@.
-}
enableHitEvents
  :: ShapeId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableHitEvents :: ShapeId -> Bool -> IO ()
enableHitEvents ShapeId
a0 Bool
a1 =
  ShapeId -> CBool -> IO ()
c_b3Shape_EnableHitEvents ShapeId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Returns true if hit events are enabled

Binds @b3Shape_AreHitEventsEnabled@.
-}
areHitEventsEnabled
  :: ShapeId
  -> IO Bool
areHitEventsEnabled :: ShapeId -> IO Bool
areHitEventsEnabled ShapeId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CBool
c_b3Shape_AreHitEventsEnabled ShapeId
a0)

{- | 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@.
-}
rayCast
  :: ShapeId
  -> Pos
  -- ^ @origin@
  -> Vec3
  -- ^ @translation@
  -> IO WorldCastOutput
rayCast :: ShapeId -> Vec3 -> Vec3 -> IO WorldCastOutput
rayCast ShapeId
a0 Vec3
a1 Vec3
a2 =
  Vec3 -> (Ptr Vec3 -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec3
a1 ((Ptr Vec3 -> IO WorldCastOutput) -> IO WorldCastOutput)
-> (Ptr Vec3 -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
p1 ->
  Vec3 -> (Ptr Vec3 -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec3
a2 ((Ptr Vec3 -> IO WorldCastOutput) -> IO WorldCastOutput)
-> (Ptr Vec3 -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
p2 ->
  (Ptr WorldCastOutput -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr WorldCastOutput -> IO WorldCastOutput) -> IO WorldCastOutput)
-> (Ptr WorldCastOutput -> IO WorldCastOutput)
-> IO WorldCastOutput
forall a b. (a -> b) -> a -> b
$ \Ptr WorldCastOutput
pOut -> ShapeId -> Ptr Vec3 -> Ptr Vec3 -> Ptr WorldCastOutput -> IO ()
c_b3Shape_RayCast ShapeId
a0 Ptr Vec3
p1 Ptr Vec3
p2 Ptr WorldCastOutput
pOut IO () -> IO WorldCastOutput -> IO WorldCastOutput
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr WorldCastOutput -> IO WorldCastOutput
forall a. Storable a => Ptr a -> IO a
peek Ptr WorldCastOutput
pOut

{- | Get a copy of the shape\'s sphere. Asserts the type is correct.

Binds @b3Shape_GetSphere@.
-}
getSphere
  :: ShapeId
  -> IO Sphere
getSphere :: ShapeId -> IO Sphere
getSphere ShapeId
a0 =
  (Ptr Sphere -> IO Sphere) -> IO Sphere
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Sphere -> IO Sphere) -> IO Sphere)
-> (Ptr Sphere -> IO Sphere) -> IO Sphere
forall a b. (a -> b) -> a -> b
$ \Ptr Sphere
pOut -> ShapeId -> Ptr Sphere -> IO ()
c_b3Shape_GetSphere ShapeId
a0 Ptr Sphere
pOut IO () -> IO Sphere -> IO Sphere
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Sphere -> IO Sphere
forall a. Storable a => Ptr a -> IO a
peek Ptr Sphere
pOut

-- | Like 'getSphere', but the result is written into a caller-supplied buffer.
getSphereInto
  :: ShapeId
  -> Ptr Sphere
  -- ^ Result buffer.
  -> IO ()
getSphereInto :: ShapeId -> Ptr Sphere -> IO ()
getSphereInto ShapeId
a0 Ptr Sphere
out =
  ShapeId -> Ptr Sphere -> IO ()
c_b3Shape_GetSphere ShapeId
a0 Ptr Sphere
out

{- | Get a copy of the shape\'s capsule. Asserts the type is correct.

Binds @b3Shape_GetCapsule@.
-}
getCapsule
  :: ShapeId
  -> IO Capsule
getCapsule :: ShapeId -> IO Capsule
getCapsule ShapeId
a0 =
  (Ptr Capsule -> IO Capsule) -> IO Capsule
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Capsule -> IO Capsule) -> IO Capsule)
-> (Ptr Capsule -> IO Capsule) -> IO Capsule
forall a b. (a -> b) -> a -> b
$ \Ptr Capsule
pOut -> ShapeId -> Ptr Capsule -> IO ()
c_b3Shape_GetCapsule ShapeId
a0 Ptr Capsule
pOut IO () -> IO Capsule -> IO Capsule
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Capsule -> IO Capsule
forall a. Storable a => Ptr a -> IO a
peek Ptr Capsule
pOut

-- | Like 'getCapsule', but the result is written into a caller-supplied buffer.
getCapsuleInto
  :: ShapeId
  -> Ptr Capsule
  -- ^ Result buffer.
  -> IO ()
getCapsuleInto :: ShapeId -> Ptr Capsule -> IO ()
getCapsuleInto ShapeId
a0 Ptr Capsule
out =
  ShapeId -> Ptr Capsule -> IO ()
c_b3Shape_GetCapsule ShapeId
a0 Ptr Capsule
out

{- | Get the shape\'s convex hull. Asserts the type is correct.

Binds @b3Shape_GetHull@.
-}
getHull
  :: ShapeId
  -> IO (Ptr HullData)
getHull :: ShapeId -> IO (Ptr HullData)
getHull ShapeId
a0 =
  ShapeId -> IO (Ptr HullData)
c_b3Shape_GetHull ShapeId
a0

{- | Get the shape\'s mesh. Asserts the type is correct.

Binds @b3Shape_GetMesh@.
-}
getMesh
  :: ShapeId
  -> Ptr Mesh
  -- ^ Result buffer.
  -> IO ()
getMesh :: ShapeId -> Ptr Mesh -> IO ()
getMesh ShapeId
a0 Ptr Mesh
out =
  ShapeId -> Ptr Mesh -> IO ()
c_b3Shape_GetMesh ShapeId
a0 Ptr Mesh
out

{- | Get the shape\'s height field. Asserts the type is correct.

Binds @b3Shape_GetHeightField@.
-}
getHeightField
  :: ShapeId
  -> IO (Ptr HeightFieldData)
getHeightField :: ShapeId -> IO (Ptr HeightFieldData)
getHeightField ShapeId
a0 =
  ShapeId -> IO (Ptr HeightFieldData)
c_b3Shape_GetHeightField ShapeId
a0

{- | 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@.
-}
setSphere
  :: ShapeId
  -> Sphere
  -> IO ()
setSphere :: ShapeId -> Sphere -> IO ()
setSphere ShapeId
a0 Sphere
a1 =
  Sphere -> (Ptr Sphere -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Sphere
a1 ((Ptr Sphere -> IO ()) -> IO ()) -> (Ptr Sphere -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Sphere
p1 ->
  ShapeId -> Ptr Sphere -> IO ()
c_b3Shape_SetSphere ShapeId
a0 Ptr Sphere
p1

{- | 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@.
-}
setCapsule
  :: ShapeId
  -> Capsule
  -> IO ()
setCapsule :: ShapeId -> Capsule -> IO ()
setCapsule ShapeId
a0 Capsule
a1 =
  Capsule -> (Ptr Capsule -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Capsule
a1 ((Ptr Capsule -> IO ()) -> IO ())
-> (Ptr Capsule -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Capsule
p1 ->
  ShapeId -> Ptr Capsule -> IO ()
c_b3Shape_SetCapsule ShapeId
a0 Ptr Capsule
p1

{- | 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@.
-}
setHull
  :: ShapeId
  -> Ptr HullData
  -> IO ()
setHull :: ShapeId -> Ptr HullData -> IO ()
setHull ShapeId
a0 Ptr HullData
a1 =
  ShapeId -> Ptr HullData -> IO ()
c_b3Shape_SetHull ShapeId
a0 Ptr HullData
a1

{- | 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@.
-}
setMesh
  :: ShapeId
  -> Ptr MeshData
  -> Vec3
  -- ^ @scale@
  -> IO ()
setMesh :: ShapeId -> Ptr MeshData -> Vec3 -> IO ()
setMesh ShapeId
a0 Ptr MeshData
a1 Vec3
a2 =
  Vec3 -> (Ptr Vec3 -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec3
a2 ((Ptr Vec3 -> IO ()) -> IO ()) -> (Ptr Vec3 -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
p2 ->
  ShapeId -> Ptr MeshData -> Ptr Vec3 -> IO ()
c_b3Shape_SetMesh ShapeId
a0 Ptr MeshData
a1 Ptr Vec3
p2

{- | Get the maximum capacity required for retrieving all the touching contacts on a shape

Binds @b3Shape_GetContactCapacity@.
-}
getContactCapacity
  :: ShapeId
  -> IO Int
getContactCapacity :: ShapeId -> IO Int
getContactCapacity ShapeId
a0 =
  CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CInt -> Int) -> IO CInt -> IO Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CInt
c_b3Shape_GetContactCapacity ShapeId
a0)

{- | 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@.
-}
getContactData
  :: ShapeId
  -> Ptr ContactData
  -> Int
  -- ^ @capacity@
  -> IO Int
getContactData :: ShapeId -> Ptr ContactData -> Int -> IO Int
getContactData ShapeId
a0 Ptr ContactData
a1 Int
a2 =
  CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CInt -> Int) -> IO CInt -> IO Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> Ptr ContactData -> CInt -> IO CInt
c_b3Shape_GetContactData ShapeId
a0 Ptr ContactData
a1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2))

{- | 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@.
-}
getSensorCapacity
  :: ShapeId
  -- ^ @shapeId@: the id of a sensor shape
  -> IO Int
getSensorCapacity :: ShapeId -> IO Int
getSensorCapacity ShapeId
a0 =
  CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CInt -> Int) -> IO CInt -> IO Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> IO CInt
c_b3Shape_GetSensorCapacity ShapeId
a0)

{- | 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@.
-}
getSensorData
  :: ShapeId
  -- ^ @shapeId@: the id of a sensor shape
  -> Ptr ShapeId
  -- ^ @visitorIds@: a user allocated array that is filled with the overlapping shapes (visitors)
  -> Int
  -- ^ @capacity@: the capacity of overlappedShapes
  -> IO Int
getSensorData :: ShapeId -> Ptr ShapeId -> Int -> IO Int
getSensorData ShapeId
a0 Ptr ShapeId
a1 Int
a2 =
  CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CInt -> Int) -> IO CInt -> IO Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ShapeId -> Ptr ShapeId -> CInt -> IO CInt
c_b3Shape_GetSensorData ShapeId
a0 Ptr ShapeId
a1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2))

{- | Get the current world AABB

Binds @b3Shape_GetAABB@.
-}
getAABB
  :: ShapeId
  -> IO AABB
getAABB :: ShapeId -> IO AABB
getAABB ShapeId
a0 =
  (Ptr AABB -> IO AABB) -> IO AABB
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr AABB -> IO AABB) -> IO AABB)
-> (Ptr AABB -> IO AABB) -> IO AABB
forall a b. (a -> b) -> a -> b
$ \Ptr AABB
pOut -> ShapeId -> Ptr AABB -> IO ()
c_b3Shape_GetAABB ShapeId
a0 Ptr AABB
pOut IO () -> IO AABB -> IO AABB
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr AABB -> IO AABB
forall a. Storable a => Ptr a -> IO a
peek Ptr AABB
pOut

-- | Like 'getAABB', but the result is written into a caller-supplied buffer.
getAABBInto
  :: ShapeId
  -> Ptr AABB
  -- ^ Result buffer.
  -> IO ()
getAABBInto :: ShapeId -> Ptr AABB -> IO ()
getAABBInto ShapeId
a0 Ptr AABB
out =
  ShapeId -> Ptr AABB -> IO ()
c_b3Shape_GetAABB ShapeId
a0 Ptr AABB
out

{- | Compute the mass data for a shape

Binds @b3Shape_ComputeMassData@.
-}
computeMassData
  :: ShapeId
  -> IO MassData
computeMassData :: ShapeId -> IO MassData
computeMassData ShapeId
a0 =
  (Ptr MassData -> IO MassData) -> IO MassData
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr MassData -> IO MassData) -> IO MassData)
-> (Ptr MassData -> IO MassData) -> IO MassData
forall a b. (a -> b) -> a -> b
$ \Ptr MassData
pOut -> ShapeId -> Ptr MassData -> IO ()
c_b3Shape_ComputeMassData ShapeId
a0 Ptr MassData
pOut IO () -> IO MassData -> IO MassData
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr MassData -> IO MassData
forall a. Storable a => Ptr a -> IO a
peek Ptr MassData
pOut

-- | Like 'computeMassData', but the result is written into a caller-supplied buffer.
computeMassDataInto
  :: ShapeId
  -> Ptr MassData
  -- ^ Result buffer.
  -> IO ()
computeMassDataInto :: ShapeId -> Ptr MassData -> IO ()
computeMassDataInto ShapeId
a0 Ptr MassData
out =
  ShapeId -> Ptr MassData -> IO ()
c_b3Shape_ComputeMassData ShapeId
a0 Ptr MassData
out

{- | Get the closest point on a shape to a target point. Target and result are in world space.

Binds @b3Shape_GetClosestPoint@.
-}
getClosestPoint
  :: ShapeId
  -> Vec3
  -- ^ @target@
  -> IO Vec3
getClosestPoint :: ShapeId -> Vec3 -> IO Vec3
getClosestPoint ShapeId
a0 Vec3
a1 =
  Vec3 -> (Ptr Vec3 -> IO Vec3) -> IO Vec3
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec3
a1 ((Ptr Vec3 -> IO Vec3) -> IO Vec3)
-> (Ptr Vec3 -> IO Vec3) -> IO Vec3
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
p1 ->
  (Ptr Vec3 -> IO Vec3) -> IO Vec3
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Vec3 -> IO Vec3) -> IO Vec3)
-> (Ptr Vec3 -> IO Vec3) -> IO Vec3
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
pOut -> ShapeId -> Ptr Vec3 -> Ptr Vec3 -> IO ()
c_b3Shape_GetClosestPoint ShapeId
a0 Ptr Vec3
p1 Ptr Vec3
pOut IO () -> IO Vec3 -> IO Vec3
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Vec3 -> IO Vec3
forall a. Storable a => Ptr a -> IO a
peek Ptr Vec3
pOut

{- | 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@.
-}
applyWind
  :: ShapeId
  -- ^ @shapeId@: the shape id
  -> Vec3
  -- ^ @wind@: the wind velocity in world space
  -> Float
  -- ^ @drag@: the drag coefficient, the force that opposes the relative velocity
  -> Float
  -- ^ @lift@: the lift coefficient, the force that is perpendicular to the relative velocity
  -> Float
  -- ^ @maxSpeed@: the maximum relative speed. Speed cap is necessary for stability. Typically 10m\/s or less.
  -> Bool
  -- ^ @wake@: should this wake the body
  -> IO ()
applyWind :: ShapeId -> Vec3 -> Float -> Float -> Float -> Bool -> IO ()
applyWind ShapeId
a0 Vec3
a1 Float
a2 Float
a3 Float
a4 Bool
a5 =
  Vec3 -> (Ptr Vec3 -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec3
a1 ((Ptr Vec3 -> IO ()) -> IO ()) -> (Ptr Vec3 -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Vec3
p1 ->
  ShapeId -> Ptr Vec3 -> Float -> Float -> Float -> CBool -> IO ()
c_b3Shape_ApplyWind ShapeId
a0 Ptr Vec3
p1 Float
a2 Float
a3 Float
a4 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a5)