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

module Box2D.Shape
  ( createCircle
  , createSegment
  , createChainSegment
  , createCapsule
  , createPolygon
  , destroy
  , isValid
  , getType
  , getBody
  , getWorld
  , isSensor
  , setUserData
  , getUserData
  , setDensity
  , getDensity
  , setFriction
  , getFriction
  , setRestitution
  , getRestitution
  , setUserMaterial
  , getUserMaterial
  , setSurfaceMaterial
  , getSurfaceMaterial
  , getSurfaceMaterialInto
  , getFilter
  , getFilterInto
  , setFilter
  , enableSensorEvents
  , areSensorEventsEnabled
  , enableContactEvents
  , areContactEventsEnabled
  , enablePreSolveEvents
  , arePreSolveEventsEnabled
  , enableHitEvents
  , areHitEventsEnabled
  , testPoint
  , rayCast
  , getCircle
  , getCircleInto
  , getSegment
  , getSegmentInto
  , getChainSegment
  , getCapsule
  , getCapsuleInto
  , getPolygon
  , getPolygonInto
  , setCircle
  , setCapsule
  , setSegment
  , setPolygon
  , setChainSegment
  , getParentChain
  , getContactCapacity
  , getContactData
  , getSensorCapacity
  , getSensorData
  , getAABB
  , getAABBInto
  , computeMassData
  , computeMassDataInto
  , getClosestPoint
  , applyWind
  )

  where

import Foreign
import Foreign.C.Types (CBool(..), CInt(..))
import Data.Coerce (coerce)
import Box2D.Id (BodyId(..), ChainId(..), ShapeId(..), WorldId(..))
import Box2D.MathTypes (AABB, Pos, Vec2)
import Box2D.Tags (ChainSegment, ContactData)
import Box2D.Types (Capsule, Circle, Filter, MassData, Polygon, Segment, ShapeDef, ShapeType(..), SurfaceMaterial, WorldCastOutput)

foreign import ccall unsafe "b2CreateCircleShape"
  c_b2CreateCircleShape :: BodyId -> Ptr ShapeDef -> Ptr Circle -> IO ShapeId

foreign import ccall unsafe "b2CreateSegmentShape"
  c_b2CreateSegmentShape :: BodyId -> Ptr ShapeDef -> Ptr Segment -> IO ShapeId

foreign import ccall unsafe "b2CreateChainSegmentShape"
  c_b2CreateChainSegmentShape :: BodyId -> Ptr ShapeDef -> Ptr ChainSegment -> IO ShapeId

foreign import ccall unsafe "b2CreateCapsuleShape"
  c_b2CreateCapsuleShape :: BodyId -> Ptr ShapeDef -> Ptr Capsule -> IO ShapeId

foreign import ccall unsafe "b2CreatePolygonShape"
  c_b2CreatePolygonShape :: BodyId -> Ptr ShapeDef -> Ptr Polygon -> IO ShapeId

foreign import ccall unsafe "b2DestroyShape"
  c_b2DestroyShape :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b2Shape_IsValid"
  c_b2Shape_IsValid :: ShapeId -> IO CBool

foreign import ccall unsafe "b2Shape_GetType"
  c_b2Shape_GetType :: ShapeId -> IO CInt

foreign import ccall unsafe "b2Shape_GetBody"
  c_b2Shape_GetBody :: ShapeId -> IO BodyId

foreign import ccall unsafe "b2Shape_GetWorld"
  c_b2Shape_GetWorld :: ShapeId -> IO WorldId

foreign import ccall unsafe "b2Shape_IsSensor"
  c_b2Shape_IsSensor :: ShapeId -> IO CBool

foreign import ccall unsafe "b2Shape_SetUserData"
  c_b2Shape_SetUserData :: ShapeId -> Ptr () -> IO ()

foreign import ccall unsafe "b2Shape_GetUserData"
  c_b2Shape_GetUserData :: ShapeId -> IO (Ptr ())

foreign import ccall unsafe "b2Shape_SetDensity"
  c_b2Shape_SetDensity :: ShapeId -> Float -> CBool -> IO ()

foreign import ccall unsafe "b2Shape_GetDensity"
  c_b2Shape_GetDensity :: ShapeId -> IO Float

foreign import ccall unsafe "b2Shape_SetFriction"
  c_b2Shape_SetFriction :: ShapeId -> Float -> IO ()

foreign import ccall unsafe "b2Shape_GetFriction"
  c_b2Shape_GetFriction :: ShapeId -> IO Float

foreign import ccall unsafe "b2Shape_SetRestitution"
  c_b2Shape_SetRestitution :: ShapeId -> Float -> IO ()

foreign import ccall unsafe "b2Shape_GetRestitution"
  c_b2Shape_GetRestitution :: ShapeId -> IO Float

foreign import ccall unsafe "b2Shape_SetUserMaterial"
  c_b2Shape_SetUserMaterial :: ShapeId -> Word64 -> IO ()

foreign import ccall unsafe "b2Shape_GetUserMaterial"
  c_b2Shape_GetUserMaterial :: ShapeId -> IO Word64

foreign import ccall unsafe "b2Shape_SetSurfaceMaterial"
  c_b2Shape_SetSurfaceMaterial :: ShapeId -> Ptr SurfaceMaterial -> IO ()

foreign import ccall unsafe "hsg_b2Shape_GetSurfaceMaterial"
  c_b2Shape_GetSurfaceMaterial :: ShapeId -> Ptr SurfaceMaterial -> IO ()

foreign import ccall unsafe "hsg_b2Shape_GetFilter"
  c_b2Shape_GetFilter :: ShapeId -> Ptr Filter -> IO ()

foreign import ccall unsafe "hsg_b2Shape_SetFilter"
  c_b2Shape_SetFilter :: ShapeId -> Ptr Filter -> IO ()

foreign import ccall unsafe "b2Shape_EnableSensorEvents"
  c_b2Shape_EnableSensorEvents :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b2Shape_AreSensorEventsEnabled"
  c_b2Shape_AreSensorEventsEnabled :: ShapeId -> IO CBool

foreign import ccall unsafe "b2Shape_EnableContactEvents"
  c_b2Shape_EnableContactEvents :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b2Shape_AreContactEventsEnabled"
  c_b2Shape_AreContactEventsEnabled :: ShapeId -> IO CBool

foreign import ccall unsafe "b2Shape_EnablePreSolveEvents"
  c_b2Shape_EnablePreSolveEvents :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b2Shape_ArePreSolveEventsEnabled"
  c_b2Shape_ArePreSolveEventsEnabled :: ShapeId -> IO CBool

foreign import ccall unsafe "b2Shape_EnableHitEvents"
  c_b2Shape_EnableHitEvents :: ShapeId -> CBool -> IO ()

foreign import ccall unsafe "b2Shape_AreHitEventsEnabled"
  c_b2Shape_AreHitEventsEnabled :: ShapeId -> IO CBool

foreign import ccall unsafe "hsg_b2Shape_TestPoint"
  c_b2Shape_TestPoint :: ShapeId -> Ptr Pos -> IO CBool

foreign import ccall unsafe "hsg_b2Shape_RayCast"
  c_b2Shape_RayCast :: ShapeId -> Ptr Pos -> Ptr Vec2 -> Ptr WorldCastOutput -> IO ()

foreign import ccall unsafe "hsg_b2Shape_GetCircle"
  c_b2Shape_GetCircle :: ShapeId -> Ptr Circle -> IO ()

foreign import ccall unsafe "hsg_b2Shape_GetSegment"
  c_b2Shape_GetSegment :: ShapeId -> Ptr Segment -> IO ()

foreign import ccall unsafe "hsg_b2Shape_GetChainSegment"
  c_b2Shape_GetChainSegment :: ShapeId -> Ptr ChainSegment -> IO ()

foreign import ccall unsafe "hsg_b2Shape_GetCapsule"
  c_b2Shape_GetCapsule :: ShapeId -> Ptr Capsule -> IO ()

foreign import ccall unsafe "hsg_b2Shape_GetPolygon"
  c_b2Shape_GetPolygon :: ShapeId -> Ptr Polygon -> IO ()

foreign import ccall unsafe "b2Shape_SetCircle"
  c_b2Shape_SetCircle :: ShapeId -> Ptr Circle -> IO ()

foreign import ccall unsafe "b2Shape_SetCapsule"
  c_b2Shape_SetCapsule :: ShapeId -> Ptr Capsule -> IO ()

foreign import ccall unsafe "b2Shape_SetSegment"
  c_b2Shape_SetSegment :: ShapeId -> Ptr Segment -> IO ()

foreign import ccall unsafe "b2Shape_SetPolygon"
  c_b2Shape_SetPolygon :: ShapeId -> Ptr Polygon -> IO ()

foreign import ccall unsafe "b2Shape_SetChainSegment"
  c_b2Shape_SetChainSegment :: ShapeId -> Ptr ChainSegment -> IO ()

foreign import ccall unsafe "b2Shape_GetParentChain"
  c_b2Shape_GetParentChain :: ShapeId -> IO ChainId

foreign import ccall unsafe "b2Shape_GetContactCapacity"
  c_b2Shape_GetContactCapacity :: ShapeId -> IO CInt

foreign import ccall unsafe "b2Shape_GetContactData"
  c_b2Shape_GetContactData :: ShapeId -> Ptr ContactData -> CInt -> IO CInt

foreign import ccall unsafe "b2Shape_GetSensorCapacity"
  c_b2Shape_GetSensorCapacity :: ShapeId -> IO CInt

foreign import ccall unsafe "b2Shape_GetSensorData"
  c_b2Shape_GetSensorData :: ShapeId -> Ptr ShapeId -> CInt -> IO CInt

foreign import ccall unsafe "hsg_b2Shape_GetAABB"
  c_b2Shape_GetAABB :: ShapeId -> Ptr AABB -> IO ()

foreign import ccall unsafe "hsg_b2Shape_ComputeMassData"
  c_b2Shape_ComputeMassData :: ShapeId -> Ptr MassData -> IO ()

foreign import ccall unsafe "hsg_b2Shape_GetClosestPoint"
  c_b2Shape_GetClosestPoint :: ShapeId -> Ptr Pos -> Ptr Pos -> IO ()

foreign import ccall unsafe "hsg_b2Shape_ApplyWind"
  c_b2Shape_ApplyWind :: ShapeId -> Ptr Vec2 -> 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 @b2CreateCircleShape@.
-}
createCircle
  :: BodyId
  -> ShapeDef
  -> Circle
  -> IO ShapeId
createCircle :: BodyId -> ShapeDef -> Circle -> IO ShapeId
createCircle BodyId
a0 ShapeDef
a1 Circle
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 ->
  Circle -> (Ptr Circle -> IO ShapeId) -> IO ShapeId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Circle
a2 ((Ptr Circle -> IO ShapeId) -> IO ShapeId)
-> (Ptr Circle -> IO ShapeId) -> IO ShapeId
forall a b. (a -> b) -> a -> b
$ \Ptr Circle
p2 ->
  BodyId -> Ptr ShapeDef -> Ptr Circle -> IO ShapeId
c_b2CreateCircleShape BodyId
a0 Ptr ShapeDef
p1 Ptr Circle
p2

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

{- | 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@.
-}
createChainSegment
  :: BodyId
  -> ShapeDef
  -> Ptr ChainSegment
  -> IO ShapeId
createChainSegment :: BodyId -> ShapeDef -> Ptr ChainSegment -> IO ShapeId
createChainSegment BodyId
a0 ShapeDef
a1 Ptr ChainSegment
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 ChainSegment -> IO ShapeId
c_b2CreateChainSegmentShape BodyId
a0 Ptr ShapeDef
p1 Ptr ChainSegment
a2

{- | 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@.
-}
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_b2CreateCapsuleShape BodyId
a0 Ptr ShapeDef
p1 Ptr Capsule
p2

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

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

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

Binds @b2Shape_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_b2Shape_IsValid ShapeId
a0)

{- | Get the type of a shape

Binds @b2Shape_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_b2Shape_GetType ShapeId
a0)

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

Binds @b2Shape_GetBody@.
-}
getBody
  :: ShapeId
  -> IO BodyId
getBody :: ShapeId -> IO BodyId
getBody ShapeId
a0 =
  ShapeId -> IO BodyId
c_b2Shape_GetBody ShapeId
a0

{- | Get the world that owns this shape

Binds @b2Shape_GetWorld@.
-}
getWorld
  :: ShapeId
  -> IO WorldId
getWorld :: ShapeId -> IO WorldId
getWorld ShapeId
a0 =
  ShapeId -> IO WorldId
c_b2Shape_GetWorld ShapeId
a0

{- | 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@.
-}
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_b2Shape_IsSensor ShapeId
a0)

{- | Set the user data for a shape

Binds @b2Shape_SetUserData@.
-}
setUserData
  :: ShapeId
  -> Ptr ()
  -- ^ @userData@
  -> IO ()
setUserData :: ShapeId -> Ptr () -> IO ()
setUserData ShapeId
a0 Ptr ()
a1 =
  ShapeId -> Ptr () -> IO ()
c_b2Shape_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 @b2Shape_GetUserData@.
-}
getUserData
  :: ShapeId
  -> IO (Ptr ())
getUserData :: ShapeId -> IO (Ptr ())
getUserData ShapeId
a0 =
  ShapeId -> IO (Ptr ())
c_b2Shape_GetUserData ShapeId
a0

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

Binds @b2Shape_GetDensity@.
-}
getDensity
  :: ShapeId
  -> IO Float
getDensity :: ShapeId -> IO Float
getDensity ShapeId
a0 =
  ShapeId -> IO Float
c_b2Shape_GetDensity ShapeId
a0

{- | Set the friction on a shape

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

{- | Get the friction of a shape

Binds @b2Shape_GetFriction@.
-}
getFriction
  :: ShapeId
  -> IO Float
getFriction :: ShapeId -> IO Float
getFriction ShapeId
a0 =
  ShapeId -> IO Float
c_b2Shape_GetFriction ShapeId
a0

{- | Set the shape restitution (bounciness)

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

{- | Get the shape restitution

Binds @b2Shape_GetRestitution@.
-}
getRestitution
  :: ShapeId
  -> IO Float
getRestitution :: ShapeId -> IO Float
getRestitution ShapeId
a0 =
  ShapeId -> IO Float
c_b2Shape_GetRestitution ShapeId
a0

{- | Set the user material identifier

Binds @b2Shape_SetUserMaterial@.
-}
setUserMaterial
  :: ShapeId
  -> Word64
  -- ^ @material@
  -> IO ()
setUserMaterial :: ShapeId -> Word64 -> IO ()
setUserMaterial ShapeId
a0 Word64
a1 =
  ShapeId -> Word64 -> IO ()
c_b2Shape_SetUserMaterial ShapeId
a0 Word64
a1

{- | Get the user material identifier

Binds @b2Shape_GetUserMaterial@.
-}
getUserMaterial
  :: ShapeId
  -> IO Word64
getUserMaterial :: ShapeId -> IO Word64
getUserMaterial ShapeId
a0 =
  ShapeId -> IO Word64
c_b2Shape_GetUserMaterial ShapeId
a0

{- | Set the shape surface material

Binds @b2Shape_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_b2Shape_SetSurfaceMaterial ShapeId
a0 Ptr SurfaceMaterial
p1

{- | Get the shape surface material

Binds @b2Shape_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_b2Shape_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_b2Shape_GetSurfaceMaterial ShapeId
a0 Ptr SurfaceMaterial
out

{- | Get the shape filter

Binds @b2Shape_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_b2Shape_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_b2Shape_GetFilter ShapeId
a0 Ptr Filter
out

{- | 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@.
-}
setFilter
  :: ShapeId
  -> Filter
  -> IO ()
setFilter :: ShapeId -> Filter -> IO ()
setFilter ShapeId
a0 Filter
a1 =
  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 -> IO ()
c_b2Shape_SetFilter ShapeId
a0 Ptr Filter
p1

{- | Enable sensor events for this shape.
See also b2ShapeDef::enableSensorEvents.

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

{- | Returns true if sensor events are enabled.

Binds @b2Shape_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_b2Shape_AreSensorEventsEnabled ShapeId
a0)

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

{- | Returns true if contact events are enabled

Binds @b2Shape_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_b2Shape_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 b2PreSolveFcn.

Binds @b2Shape_EnablePreSolveEvents@.
-}
enablePreSolveEvents
  :: ShapeId
  -> Bool
  -- ^ @flag@
  -> IO ()
enablePreSolveEvents :: ShapeId -> Bool -> IO ()
enablePreSolveEvents ShapeId
a0 Bool
a1 =
  ShapeId -> CBool -> IO ()
c_b2Shape_EnablePreSolveEvents ShapeId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

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

Binds @b2Shape_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_b2Shape_ArePreSolveEventsEnabled ShapeId
a0)

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

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

{- | Returns true if hit events are enabled

Binds @b2Shape_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_b2Shape_AreHitEventsEnabled ShapeId
a0)

{- | Test a world point for overlap with a shape

Binds @b2Shape_TestPoint@.
-}
testPoint
  :: ShapeId
  -> Pos
  -- ^ @point@
  -> IO Bool
testPoint :: ShapeId -> Vec2 -> IO Bool
testPoint ShapeId
a0 Vec2
a1 =
  Vec2 -> (Ptr Vec2 -> IO Bool) -> IO Bool
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO Bool) -> IO Bool)
-> (Ptr Vec2 -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  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 -> Ptr Vec2 -> IO CBool
c_b2Shape_TestPoint ShapeId
a0 Ptr Vec2
p1)

{- | 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@.
-}
rayCast
  :: ShapeId
  -> Pos
  -- ^ @origin@
  -> Vec2
  -- ^ @translation@
  -> IO WorldCastOutput
rayCast :: ShapeId -> Vec2 -> Vec2 -> IO WorldCastOutput
rayCast ShapeId
a0 Vec2
a1 Vec2
a2 =
  Vec2 -> (Ptr Vec2 -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO WorldCastOutput) -> IO WorldCastOutput)
-> (Ptr Vec2 -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  Vec2 -> (Ptr Vec2 -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a2 ((Ptr Vec2 -> IO WorldCastOutput) -> IO WorldCastOutput)
-> (Ptr Vec2 -> IO WorldCastOutput) -> IO WorldCastOutput
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
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 Vec2 -> Ptr Vec2 -> Ptr WorldCastOutput -> IO ()
c_b2Shape_RayCast ShapeId
a0 Ptr Vec2
p1 Ptr Vec2
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 circle. Asserts the type is correct.

Binds @b2Shape_GetCircle@.
-}
getCircle
  :: ShapeId
  -> IO Circle
getCircle :: ShapeId -> IO Circle
getCircle ShapeId
a0 =
  (Ptr Circle -> IO Circle) -> IO Circle
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Circle -> IO Circle) -> IO Circle)
-> (Ptr Circle -> IO Circle) -> IO Circle
forall a b. (a -> b) -> a -> b
$ \Ptr Circle
pOut -> ShapeId -> Ptr Circle -> IO ()
c_b2Shape_GetCircle ShapeId
a0 Ptr Circle
pOut IO () -> IO Circle -> IO Circle
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Circle -> IO Circle
forall a. Storable a => Ptr a -> IO a
peek Ptr Circle
pOut

-- | Like 'getCircle', but the result is written into a caller-supplied buffer.
getCircleInto
  :: ShapeId
  -> Ptr Circle
  -- ^ Result buffer.
  -> IO ()
getCircleInto :: ShapeId -> Ptr Circle -> IO ()
getCircleInto ShapeId
a0 Ptr Circle
out =
  ShapeId -> Ptr Circle -> IO ()
c_b2Shape_GetCircle ShapeId
a0 Ptr Circle
out

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

Binds @b2Shape_GetSegment@.
-}
getSegment
  :: ShapeId
  -> IO Segment
getSegment :: ShapeId -> IO Segment
getSegment ShapeId
a0 =
  (Ptr Segment -> IO Segment) -> IO Segment
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Segment -> IO Segment) -> IO Segment)
-> (Ptr Segment -> IO Segment) -> IO Segment
forall a b. (a -> b) -> a -> b
$ \Ptr Segment
pOut -> ShapeId -> Ptr Segment -> IO ()
c_b2Shape_GetSegment ShapeId
a0 Ptr Segment
pOut IO () -> IO Segment -> IO Segment
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Segment -> IO Segment
forall a. Storable a => Ptr a -> IO a
peek Ptr Segment
pOut

-- | Like 'getSegment', but the result is written into a caller-supplied buffer.
getSegmentInto
  :: ShapeId
  -> Ptr Segment
  -- ^ Result buffer.
  -> IO ()
getSegmentInto :: ShapeId -> Ptr Segment -> IO ()
getSegmentInto ShapeId
a0 Ptr Segment
out =
  ShapeId -> Ptr Segment -> IO ()
c_b2Shape_GetSegment ShapeId
a0 Ptr Segment
out

{- | Get a copy of the shape\'s chain segment. These come from chain shapes.
Asserts the type is correct.

Binds @b2Shape_GetChainSegment@.
-}
getChainSegment
  :: ShapeId
  -> Ptr ChainSegment
  -- ^ Result buffer.
  -> IO ()
getChainSegment :: ShapeId -> Ptr ChainSegment -> IO ()
getChainSegment ShapeId
a0 Ptr ChainSegment
out =
  ShapeId -> Ptr ChainSegment -> IO ()
c_b2Shape_GetChainSegment ShapeId
a0 Ptr ChainSegment
out

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

Binds @b2Shape_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_b2Shape_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_b2Shape_GetCapsule ShapeId
a0 Ptr Capsule
out

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

Binds @b2Shape_GetPolygon@.
-}
getPolygon
  :: ShapeId
  -> IO Polygon
getPolygon :: ShapeId -> IO Polygon
getPolygon ShapeId
a0 =
  (Ptr Polygon -> IO Polygon) -> IO Polygon
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Polygon -> IO Polygon) -> IO Polygon)
-> (Ptr Polygon -> IO Polygon) -> IO Polygon
forall a b. (a -> b) -> a -> b
$ \Ptr Polygon
pOut -> ShapeId -> Ptr Polygon -> IO ()
c_b2Shape_GetPolygon ShapeId
a0 Ptr Polygon
pOut IO () -> IO Polygon -> IO Polygon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Polygon -> IO Polygon
forall a. Storable a => Ptr a -> IO a
peek Ptr Polygon
pOut

-- | Like 'getPolygon', but the result is written into a caller-supplied buffer.
getPolygonInto
  :: ShapeId
  -> Ptr Polygon
  -- ^ Result buffer.
  -> IO ()
getPolygonInto :: ShapeId -> Ptr Polygon -> IO ()
getPolygonInto ShapeId
a0 Ptr Polygon
out =
  ShapeId -> Ptr Polygon -> IO ()
c_b2Shape_GetPolygon ShapeId
a0 Ptr Polygon
out

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

Binds @b2Shape_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_b2Shape_SetCapsule ShapeId
a0 Ptr Capsule
p1

{- | Allows you to change a shape to be a segment or update the current segment.

Binds @b2Shape_SetSegment@.
-}
setSegment
  :: ShapeId
  -> Segment
  -> IO ()
setSegment :: ShapeId -> Segment -> IO ()
setSegment ShapeId
a0 Segment
a1 =
  Segment -> (Ptr Segment -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Segment
a1 ((Ptr Segment -> IO ()) -> IO ())
-> (Ptr Segment -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Segment
p1 ->
  ShapeId -> Ptr Segment -> IO ()
c_b2Shape_SetSegment ShapeId
a0 Ptr Segment
p1

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

{- | 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@.
-}
setChainSegment
  :: ShapeId
  -> Ptr ChainSegment
  -> IO ()
setChainSegment :: ShapeId -> Ptr ChainSegment -> IO ()
setChainSegment ShapeId
a0 Ptr ChainSegment
a1 =
  ShapeId -> Ptr ChainSegment -> IO ()
c_b2Shape_SetChainSegment ShapeId
a0 Ptr ChainSegment
a1

{- | Get the parent chain id if the shape type is a chain segment, otherwise
returns b2_nullChainId.

Binds @b2Shape_GetParentChain@.
-}
getParentChain
  :: ShapeId
  -> IO ChainId
getParentChain :: ShapeId -> IO ChainId
getParentChain ShapeId
a0 =
  ShapeId -> IO ChainId
c_b2Shape_GetParentChain ShapeId
a0

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

Binds @b2Shape_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_b2Shape_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: 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@.
-}
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_b2Shape_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 b2Shape_GetSensorData

Binds @b2Shape_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_b2Shape_GetSensorCapacity ShapeId
a0)

{- | 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@.
-}
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_b2Shape_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 @b2Shape_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_b2Shape_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_b2Shape_GetAABB ShapeId
a0 Ptr AABB
out

{- | Compute the mass data for a shape

Binds @b2Shape_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_b2Shape_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_b2Shape_ComputeMassData ShapeId
a0 Ptr MassData
out

{- | Get the closest point on a shape to a target point. Target and result are world positions.
todo need sample

Binds @b2Shape_GetClosestPoint@.
-}
getClosestPoint
  :: ShapeId
  -> Pos
  -- ^ @target@
  -> IO Pos
getClosestPoint :: ShapeId -> Vec2 -> IO Vec2
getClosestPoint ShapeId
a0 Vec2
a1 =
  Vec2 -> (Ptr Vec2 -> IO Vec2) -> IO Vec2
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO Vec2) -> IO Vec2)
-> (Ptr Vec2 -> IO Vec2) -> IO Vec2
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  (Ptr Vec2 -> IO Vec2) -> IO Vec2
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Vec2 -> IO Vec2) -> IO Vec2)
-> (Ptr Vec2 -> IO Vec2) -> IO Vec2
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
pOut -> ShapeId -> Ptr Vec2 -> Ptr Vec2 -> IO ()
c_b2Shape_GetClosestPoint ShapeId
a0 Ptr Vec2
p1 Ptr Vec2
pOut IO () -> IO Vec2 -> IO Vec2
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Vec2 -> IO Vec2
forall a. Storable a => Ptr a -> IO a
peek Ptr Vec2
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 @b2Shape_ApplyWind@.
-}
applyWind
  :: ShapeId
  -- ^ @shapeId@: the shape id
  -> Vec2
  -- ^ @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
  -> Bool
  -- ^ @wake@: should this wake the body
  -> IO ()
applyWind :: ShapeId -> Vec2 -> Float -> Float -> Bool -> IO ()
applyWind ShapeId
a0 Vec2
a1 Float
a2 Float
a3 Bool
a4 =
  Vec2 -> (Ptr Vec2 -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO ()) -> IO ()) -> (Ptr Vec2 -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  ShapeId -> Ptr Vec2 -> Float -> Float -> CBool -> IO ()
c_b2Shape_ApplyWind ShapeId
a0 Ptr Vec2
p1 Float
a2 Float
a3 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a4)