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

module Box2D.Body
  ( create
  , destroy
  , isValid
  , getType
  , setType
  , setName
  , getName
  , setUserData
  , getUserData
  , getPosition
  , getPositionInto
  , getRotation
  , getRotationInto
  , getTransform
  , getTransformInto
  , setTransform
  , getLocalPoint
  , getWorldPoint
  , getLocalVector
  , getWorldVector
  , getLinearVelocity
  , getLinearVelocityInto
  , getAngularVelocity
  , setLinearVelocity
  , setAngularVelocity
  , setTargetTransform
  , getLocalPointVelocity
  , getWorldPointVelocity
  , applyForce
  , applyForceToCenter
  , applyTorque
  , clearForces
  , applyLinearImpulse
  , applyLinearImpulseToCenter
  , applyAngularImpulse
  , getMass
  , getRotationalInertia
  , getLocalCenter
  , getLocalCenterInto
  , getWorldCenter
  , getWorldCenterInto
  , setMassData
  , getMassData
  , getMassDataInto
  , applyMassFromShapes
  , setLinearDamping
  , getLinearDamping
  , setAngularDamping
  , getAngularDamping
  , setGravityScale
  , getGravityScale
  , isAwake
  , setAwake
  , wakeTouching
  , enableSleep
  , isSleepEnabled
  , setSleepThreshold
  , getSleepThreshold
  , isEnabled
  , disable
  , enable
  , setMotionLocks
  , getMotionLocks
  , getMotionLocksInto
  , setBullet
  , isBullet
  , enableContactRecycling
  , isContactRecyclingEnabled
  , enableContactEvents
  , enableHitEvents
  , getWorld
  , getShapeCount
  , getShapes
  , getJointCount
  , getJoints
  , getContactCapacity
  , getContactData
  , computeAABB
  , computeAABBInto
  )

  where

import Foreign
import Foreign.C.Types (CBool(..), CInt(..))
import Foreign.C.String (CString)
import Data.Coerce (coerce)
import Box2D.Id (BodyId(..), JointId(..), ShapeId(..), WorldId(..))
import Box2D.MathTypes (AABB, Pos, Rot, Vec2, WorldTransform)
import Box2D.Tags (ContactData)
import Box2D.Types (BodyDef, BodyType(..), MassData, MotionLocks)

foreign import ccall unsafe "b2CreateBody"
  c_b2CreateBody :: WorldId -> Ptr BodyDef -> IO BodyId

foreign import ccall unsafe "b2DestroyBody"
  c_b2DestroyBody :: BodyId -> IO ()

foreign import ccall unsafe "b2Body_IsValid"
  c_b2Body_IsValid :: BodyId -> IO CBool

foreign import ccall unsafe "b2Body_GetType"
  c_b2Body_GetType :: BodyId -> IO CInt

foreign import ccall unsafe "b2Body_SetType"
  c_b2Body_SetType :: BodyId -> CInt -> IO ()

foreign import ccall unsafe "b2Body_SetName"
  c_b2Body_SetName :: BodyId -> CString -> IO ()

foreign import ccall unsafe "b2Body_GetName"
  c_b2Body_GetName :: BodyId -> IO CString

foreign import ccall unsafe "b2Body_SetUserData"
  c_b2Body_SetUserData :: BodyId -> Ptr () -> IO ()

foreign import ccall unsafe "b2Body_GetUserData"
  c_b2Body_GetUserData :: BodyId -> IO (Ptr ())

foreign import ccall unsafe "hsg_b2Body_GetPosition"
  c_b2Body_GetPosition :: BodyId -> Ptr Pos -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetRotation"
  c_b2Body_GetRotation :: BodyId -> Ptr Rot -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetTransform"
  c_b2Body_GetTransform :: BodyId -> Ptr WorldTransform -> IO ()

foreign import ccall unsafe "hsg_b2Body_SetTransform"
  c_b2Body_SetTransform :: BodyId -> Ptr Pos -> Ptr Rot -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetLocalPoint"
  c_b2Body_GetLocalPoint :: BodyId -> Ptr Pos -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetWorldPoint"
  c_b2Body_GetWorldPoint :: BodyId -> Ptr Vec2 -> Ptr Pos -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetLocalVector"
  c_b2Body_GetLocalVector :: BodyId -> Ptr Vec2 -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetWorldVector"
  c_b2Body_GetWorldVector :: BodyId -> Ptr Vec2 -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetLinearVelocity"
  c_b2Body_GetLinearVelocity :: BodyId -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "b2Body_GetAngularVelocity"
  c_b2Body_GetAngularVelocity :: BodyId -> IO Float

foreign import ccall unsafe "hsg_b2Body_SetLinearVelocity"
  c_b2Body_SetLinearVelocity :: BodyId -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "b2Body_SetAngularVelocity"
  c_b2Body_SetAngularVelocity :: BodyId -> Float -> IO ()

foreign import ccall unsafe "hsg_b2Body_SetTargetTransform"
  c_b2Body_SetTargetTransform :: BodyId -> Ptr WorldTransform -> Float -> CBool -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetLocalPointVelocity"
  c_b2Body_GetLocalPointVelocity :: BodyId -> Ptr Vec2 -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetWorldPointVelocity"
  c_b2Body_GetWorldPointVelocity :: BodyId -> Ptr Pos -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "hsg_b2Body_ApplyForce"
  c_b2Body_ApplyForce :: BodyId -> Ptr Vec2 -> Ptr Pos -> CBool -> IO ()

foreign import ccall unsafe "hsg_b2Body_ApplyForceToCenter"
  c_b2Body_ApplyForceToCenter :: BodyId -> Ptr Vec2 -> CBool -> IO ()

foreign import ccall unsafe "b2Body_ApplyTorque"
  c_b2Body_ApplyTorque :: BodyId -> Float -> CBool -> IO ()

foreign import ccall unsafe "b2Body_ClearForces"
  c_b2Body_ClearForces :: BodyId -> IO ()

foreign import ccall unsafe "hsg_b2Body_ApplyLinearImpulse"
  c_b2Body_ApplyLinearImpulse :: BodyId -> Ptr Vec2 -> Ptr Pos -> CBool -> IO ()

foreign import ccall unsafe "hsg_b2Body_ApplyLinearImpulseToCenter"
  c_b2Body_ApplyLinearImpulseToCenter :: BodyId -> Ptr Vec2 -> CBool -> IO ()

foreign import ccall unsafe "b2Body_ApplyAngularImpulse"
  c_b2Body_ApplyAngularImpulse :: BodyId -> Float -> CBool -> IO ()

foreign import ccall unsafe "b2Body_GetMass"
  c_b2Body_GetMass :: BodyId -> IO Float

foreign import ccall unsafe "b2Body_GetRotationalInertia"
  c_b2Body_GetRotationalInertia :: BodyId -> IO Float

foreign import ccall unsafe "hsg_b2Body_GetLocalCenter"
  c_b2Body_GetLocalCenter :: BodyId -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetWorldCenter"
  c_b2Body_GetWorldCenter :: BodyId -> Ptr Pos -> IO ()

foreign import ccall unsafe "hsg_b2Body_SetMassData"
  c_b2Body_SetMassData :: BodyId -> Ptr MassData -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetMassData"
  c_b2Body_GetMassData :: BodyId -> Ptr MassData -> IO ()

foreign import ccall unsafe "b2Body_ApplyMassFromShapes"
  c_b2Body_ApplyMassFromShapes :: BodyId -> IO ()

foreign import ccall unsafe "b2Body_SetLinearDamping"
  c_b2Body_SetLinearDamping :: BodyId -> Float -> IO ()

foreign import ccall unsafe "b2Body_GetLinearDamping"
  c_b2Body_GetLinearDamping :: BodyId -> IO Float

foreign import ccall unsafe "b2Body_SetAngularDamping"
  c_b2Body_SetAngularDamping :: BodyId -> Float -> IO ()

foreign import ccall unsafe "b2Body_GetAngularDamping"
  c_b2Body_GetAngularDamping :: BodyId -> IO Float

foreign import ccall unsafe "b2Body_SetGravityScale"
  c_b2Body_SetGravityScale :: BodyId -> Float -> IO ()

foreign import ccall unsafe "b2Body_GetGravityScale"
  c_b2Body_GetGravityScale :: BodyId -> IO Float

foreign import ccall unsafe "b2Body_IsAwake"
  c_b2Body_IsAwake :: BodyId -> IO CBool

foreign import ccall unsafe "b2Body_SetAwake"
  c_b2Body_SetAwake :: BodyId -> CBool -> IO ()

foreign import ccall unsafe "b2Body_WakeTouching"
  c_b2Body_WakeTouching :: BodyId -> IO ()

foreign import ccall unsafe "b2Body_EnableSleep"
  c_b2Body_EnableSleep :: BodyId -> CBool -> IO ()

foreign import ccall unsafe "b2Body_IsSleepEnabled"
  c_b2Body_IsSleepEnabled :: BodyId -> IO CBool

foreign import ccall unsafe "b2Body_SetSleepThreshold"
  c_b2Body_SetSleepThreshold :: BodyId -> Float -> IO ()

foreign import ccall unsafe "b2Body_GetSleepThreshold"
  c_b2Body_GetSleepThreshold :: BodyId -> IO Float

foreign import ccall unsafe "b2Body_IsEnabled"
  c_b2Body_IsEnabled :: BodyId -> IO CBool

foreign import ccall unsafe "b2Body_Disable"
  c_b2Body_Disable :: BodyId -> IO ()

foreign import ccall unsafe "b2Body_Enable"
  c_b2Body_Enable :: BodyId -> IO ()

foreign import ccall unsafe "hsg_b2Body_SetMotionLocks"
  c_b2Body_SetMotionLocks :: BodyId -> Ptr MotionLocks -> IO ()

foreign import ccall unsafe "hsg_b2Body_GetMotionLocks"
  c_b2Body_GetMotionLocks :: BodyId -> Ptr MotionLocks -> IO ()

foreign import ccall unsafe "b2Body_SetBullet"
  c_b2Body_SetBullet :: BodyId -> CBool -> IO ()

foreign import ccall unsafe "b2Body_IsBullet"
  c_b2Body_IsBullet :: BodyId -> IO CBool

foreign import ccall unsafe "b2Body_EnableContactRecycling"
  c_b2Body_EnableContactRecycling :: BodyId -> CBool -> IO ()

foreign import ccall unsafe "b2Body_IsContactRecyclingEnabled"
  c_b2Body_IsContactRecyclingEnabled :: BodyId -> IO CBool

foreign import ccall unsafe "b2Body_EnableContactEvents"
  c_b2Body_EnableContactEvents :: BodyId -> CBool -> IO ()

foreign import ccall unsafe "b2Body_EnableHitEvents"
  c_b2Body_EnableHitEvents :: BodyId -> CBool -> IO ()

foreign import ccall unsafe "b2Body_GetWorld"
  c_b2Body_GetWorld :: BodyId -> IO WorldId

foreign import ccall unsafe "b2Body_GetShapeCount"
  c_b2Body_GetShapeCount :: BodyId -> IO CInt

foreign import ccall unsafe "b2Body_GetShapes"
  c_b2Body_GetShapes :: BodyId -> Ptr ShapeId -> CInt -> IO CInt

foreign import ccall unsafe "b2Body_GetJointCount"
  c_b2Body_GetJointCount :: BodyId -> IO CInt

foreign import ccall unsafe "b2Body_GetJoints"
  c_b2Body_GetJoints :: BodyId -> Ptr JointId -> CInt -> IO CInt

foreign import ccall unsafe "b2Body_GetContactCapacity"
  c_b2Body_GetContactCapacity :: BodyId -> IO CInt

foreign import ccall unsafe "b2Body_GetContactData"
  c_b2Body_GetContactData :: BodyId -> Ptr ContactData -> CInt -> IO CInt

foreign import ccall unsafe "hsg_b2Body_ComputeAABB"
  c_b2Body_ComputeAABB :: BodyId -> Ptr AABB -> IO ()

{- | Create a rigid body given a definition. No reference to the definition is retained. So you can create the definition
on the stack and pass it as a pointer.
b2BodyDef bodyDef = b2DefaultBodyDef();
b2BodyId myBodyId = b2CreateBody(myWorldId, &bodyDef);
Warning: This function is locked during callbacks.

Binds @b2CreateBody@.
-}
create
  :: WorldId
  -> BodyDef
  -> IO BodyId
create :: WorldId -> BodyDef -> IO BodyId
create WorldId
a0 BodyDef
a1 =
  BodyDef -> (Ptr BodyDef -> IO BodyId) -> IO BodyId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with BodyDef
a1 ((Ptr BodyDef -> IO BodyId) -> IO BodyId)
-> (Ptr BodyDef -> IO BodyId) -> IO BodyId
forall a b. (a -> b) -> a -> b
$ \Ptr BodyDef
p1 ->
  WorldId -> Ptr BodyDef -> IO BodyId
c_b2CreateBody WorldId
a0 Ptr BodyDef
p1

{- | Destroy a rigid body given an id. This destroys all shapes and joints attached to the body.
Do not keep references to the associated shapes and joints.

Binds @b2DestroyBody@.
-}
destroy
  :: BodyId
  -> IO ()
destroy :: BodyId -> IO ()
destroy BodyId
a0 =
  BodyId -> IO ()
c_b2DestroyBody BodyId
a0

{- | Body identifier validation. A valid body exists in a world and is non-null.
This can be used to detect orphaned ids. Provides validation for up to 64K allocations.

Binds @b2Body_IsValid@.
-}
isValid
  :: BodyId
  -> IO Bool
isValid :: BodyId -> IO Bool
isValid BodyId
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
<$> (BodyId -> IO CBool
c_b2Body_IsValid BodyId
a0)

{- | Get the body type: static, kinematic, or dynamic

Binds @b2Body_GetType@.
-}
getType
  :: BodyId
  -> IO BodyType
getType :: BodyId -> IO BodyType
getType BodyId
a0 =
  CInt -> BodyType
forall a b. Coercible a b => a -> b
coerce (CInt -> BodyType) -> IO CInt -> IO BodyType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (BodyId -> IO CInt
c_b2Body_GetType BodyId
a0)

{- | Change the body type. This is an expensive operation. This automatically updates the mass
properties regardless of the automatic mass setting.

Binds @b2Body_SetType@.
-}
setType
  :: BodyId
  -> BodyType
  -> IO ()
setType :: BodyId -> BodyType -> IO ()
setType BodyId
a0 BodyType
a1 =
  BodyId -> CInt -> IO ()
c_b2Body_SetType BodyId
a0 (BodyType -> CInt
forall a b. Coercible a b => a -> b
coerce BodyType
a1)

{- | Set the body name. Up to 31 characters excluding 0 termination.

Binds @b2Body_SetName@.
-}
setName
  :: BodyId
  -> CString
  -- ^ @name@
  -> IO ()
setName :: BodyId -> CString -> IO ()
setName BodyId
a0 CString
a1 =
  BodyId -> CString -> IO ()
c_b2Body_SetName BodyId
a0 CString
a1

{- | Get the body name.

Binds @b2Body_GetName@.
-}
getName
  :: BodyId
  -> IO CString
getName :: BodyId -> IO CString
getName BodyId
a0 =
  BodyId -> IO CString
c_b2Body_GetName BodyId
a0

{- | Set the user data for a body

Binds @b2Body_SetUserData@.
-}
setUserData
  :: BodyId
  -> Ptr ()
  -- ^ @userData@
  -> IO ()
setUserData :: BodyId -> Ptr () -> IO ()
setUserData BodyId
a0 Ptr ()
a1 =
  BodyId -> Ptr () -> IO ()
c_b2Body_SetUserData BodyId
a0 Ptr ()
a1

{- | Get the user data stored in a body

Binds @b2Body_GetUserData@.
-}
getUserData
  :: BodyId
  -> IO (Ptr ())
getUserData :: BodyId -> IO (Ptr ())
getUserData BodyId
a0 =
  BodyId -> IO (Ptr ())
c_b2Body_GetUserData BodyId
a0

{- | Get the world position of a body. This is the location of the body origin.

Binds @b2Body_GetPosition@.
-}
getPosition
  :: BodyId
  -> IO Pos
getPosition :: BodyId -> IO Pos
getPosition BodyId
a0 =
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> IO ()
c_b2Body_GetPosition BodyId
a0 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

-- | Like 'getPosition', but the result is written into a caller-supplied buffer.
getPositionInto
  :: BodyId
  -> Ptr Pos
  -- ^ Result buffer.
  -> IO ()
getPositionInto :: BodyId -> Ptr Pos -> IO ()
getPositionInto BodyId
a0 Ptr Pos
out =
  BodyId -> Ptr Pos -> IO ()
c_b2Body_GetPosition BodyId
a0 Ptr Pos
out

{- | Get the world rotation of a body as a cosine\/sine pair (complex number)

Binds @b2Body_GetRotation@.
-}
getRotation
  :: BodyId
  -> IO Rot
getRotation :: BodyId -> IO Rot
getRotation BodyId
a0 =
  (Ptr Rot -> IO Rot) -> IO Rot
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Rot -> IO Rot) -> IO Rot) -> (Ptr Rot -> IO Rot) -> IO Rot
forall a b. (a -> b) -> a -> b
$ \Ptr Rot
pOut -> BodyId -> Ptr Rot -> IO ()
c_b2Body_GetRotation BodyId
a0 Ptr Rot
pOut IO () -> IO Rot -> IO Rot
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Rot -> IO Rot
forall a. Storable a => Ptr a -> IO a
peek Ptr Rot
pOut

-- | Like 'getRotation', but the result is written into a caller-supplied buffer.
getRotationInto
  :: BodyId
  -> Ptr Rot
  -- ^ Result buffer.
  -> IO ()
getRotationInto :: BodyId -> Ptr Rot -> IO ()
getRotationInto BodyId
a0 Ptr Rot
out =
  BodyId -> Ptr Rot -> IO ()
c_b2Body_GetRotation BodyId
a0 Ptr Rot
out

{- | Get the world transform of a body.

Binds @b2Body_GetTransform@.
-}
getTransform
  :: BodyId
  -> IO WorldTransform
getTransform :: BodyId -> IO WorldTransform
getTransform BodyId
a0 =
  (Ptr WorldTransform -> IO WorldTransform) -> IO WorldTransform
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr WorldTransform -> IO WorldTransform) -> IO WorldTransform)
-> (Ptr WorldTransform -> IO WorldTransform) -> IO WorldTransform
forall a b. (a -> b) -> a -> b
$ \Ptr WorldTransform
pOut -> BodyId -> Ptr WorldTransform -> IO ()
c_b2Body_GetTransform BodyId
a0 Ptr WorldTransform
pOut IO () -> IO WorldTransform -> IO WorldTransform
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr WorldTransform -> IO WorldTransform
forall a. Storable a => Ptr a -> IO a
peek Ptr WorldTransform
pOut

-- | Like 'getTransform', but the result is written into a caller-supplied buffer.
getTransformInto
  :: BodyId
  -> Ptr WorldTransform
  -- ^ Result buffer.
  -> IO ()
getTransformInto :: BodyId -> Ptr WorldTransform -> IO ()
getTransformInto BodyId
a0 Ptr WorldTransform
out =
  BodyId -> Ptr WorldTransform -> IO ()
c_b2Body_GetTransform BodyId
a0 Ptr WorldTransform
out

{- | Set the world transform of a body. This acts as a teleport and is fairly expensive.
Note: Generally you should create a body with then intended transform.
See also b2BodyDef::position and b2BodyDef::rotation.

Binds @b2Body_SetTransform@.
-}
setTransform
  :: BodyId
  -> Pos
  -- ^ @position@
  -> Rot
  -- ^ @rotation@
  -> IO ()
setTransform :: BodyId -> Pos -> Rot -> IO ()
setTransform BodyId
a0 Pos
a1 Rot
a2 =
  Pos -> (Ptr Pos -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO ()) -> IO ()) -> (Ptr Pos -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  Rot -> (Ptr Rot -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Rot
a2 ((Ptr Rot -> IO ()) -> IO ()) -> (Ptr Rot -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Rot
p2 ->
  BodyId -> Ptr Pos -> Ptr Rot -> IO ()
c_b2Body_SetTransform BodyId
a0 Ptr Pos
p1 Ptr Rot
p2

{- | Get a local point on a body given a world point

Binds @b2Body_GetLocalPoint@.
-}
getLocalPoint
  :: BodyId
  -> Pos
  -- ^ @worldPoint@
  -> IO Vec2
getLocalPoint :: BodyId -> Pos -> IO Pos
getLocalPoint BodyId
a0 Pos
a1 =
  Pos -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> Ptr Pos -> IO ()
c_b2Body_GetLocalPoint BodyId
a0 Ptr Pos
p1 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

{- | Get a world point on a body given a local point

Binds @b2Body_GetWorldPoint@.
-}
getWorldPoint
  :: BodyId
  -> Vec2
  -- ^ @localPoint@
  -> IO Pos
getWorldPoint :: BodyId -> Pos -> IO Pos
getWorldPoint BodyId
a0 Pos
a1 =
  Pos -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> Ptr Pos -> IO ()
c_b2Body_GetWorldPoint BodyId
a0 Ptr Pos
p1 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

{- | Get a local vector on a body given a world vector

Binds @b2Body_GetLocalVector@.
-}
getLocalVector
  :: BodyId
  -> Vec2
  -- ^ @worldVector@
  -> IO Vec2
getLocalVector :: BodyId -> Pos -> IO Pos
getLocalVector BodyId
a0 Pos
a1 =
  Pos -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> Ptr Pos -> IO ()
c_b2Body_GetLocalVector BodyId
a0 Ptr Pos
p1 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

{- | Get a world vector on a body given a local vector

Binds @b2Body_GetWorldVector@.
-}
getWorldVector
  :: BodyId
  -> Vec2
  -- ^ @localVector@
  -> IO Vec2
getWorldVector :: BodyId -> Pos -> IO Pos
getWorldVector BodyId
a0 Pos
a1 =
  Pos -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> Ptr Pos -> IO ()
c_b2Body_GetWorldVector BodyId
a0 Ptr Pos
p1 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

{- | Get the linear velocity of a body\'s center of mass. Usually in meters per second.

Binds @b2Body_GetLinearVelocity@.
-}
getLinearVelocity
  :: BodyId
  -> IO Vec2
getLinearVelocity :: BodyId -> IO Pos
getLinearVelocity BodyId
a0 =
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> IO ()
c_b2Body_GetLinearVelocity BodyId
a0 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

-- | Like 'getLinearVelocity', but the result is written into a caller-supplied buffer.
getLinearVelocityInto
  :: BodyId
  -> Ptr Vec2
  -- ^ Result buffer.
  -> IO ()
getLinearVelocityInto :: BodyId -> Ptr Pos -> IO ()
getLinearVelocityInto BodyId
a0 Ptr Pos
out =
  BodyId -> Ptr Pos -> IO ()
c_b2Body_GetLinearVelocity BodyId
a0 Ptr Pos
out

{- | Get the angular velocity of a body in radians per second

Binds @b2Body_GetAngularVelocity@.
-}
getAngularVelocity
  :: BodyId
  -> IO Float
getAngularVelocity :: BodyId -> IO Float
getAngularVelocity BodyId
a0 =
  BodyId -> IO Float
c_b2Body_GetAngularVelocity BodyId
a0

{- | Set the linear velocity of a body. Usually in meters per second.

Binds @b2Body_SetLinearVelocity@.
-}
setLinearVelocity
  :: BodyId
  -> Vec2
  -- ^ @linearVelocity@
  -> IO ()
setLinearVelocity :: BodyId -> Pos -> IO ()
setLinearVelocity BodyId
a0 Pos
a1 =
  Pos -> (Ptr Pos -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO ()) -> IO ()) -> (Ptr Pos -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  BodyId -> Ptr Pos -> IO ()
c_b2Body_SetLinearVelocity BodyId
a0 Ptr Pos
p1

{- | Set the angular velocity of a body in radians per second

Binds @b2Body_SetAngularVelocity@.
-}
setAngularVelocity
  :: BodyId
  -> Float
  -- ^ @angularVelocity@
  -> IO ()
setAngularVelocity :: BodyId -> Float -> IO ()
setAngularVelocity BodyId
a0 Float
a1 =
  BodyId -> Float -> IO ()
c_b2Body_SetAngularVelocity BodyId
a0 Float
a1

{- | Set the velocity to reach the given transform after a given time step.
The result will be close but maybe not exact. This is meant for kinematic bodies.
The target is not applied if the velocity would be below the sleep threshold and
the body is currently asleep.

Binds @b2Body_SetTargetTransform@.
-}
setTargetTransform
  :: BodyId
  -- ^ @bodyId@: The body id
  -> WorldTransform
  -- ^ @target@: The target transform for the body
  -> Float
  -- ^ @timeStep@: The time step of the next call to b2World_Step
  -> Bool
  -- ^ @wake@: Option to wake the body or not
  -> IO ()
setTargetTransform :: BodyId -> WorldTransform -> Float -> Bool -> IO ()
setTargetTransform BodyId
a0 WorldTransform
a1 Float
a2 Bool
a3 =
  WorldTransform -> (Ptr WorldTransform -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with WorldTransform
a1 ((Ptr WorldTransform -> IO ()) -> IO ())
-> (Ptr WorldTransform -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr WorldTransform
p1 ->
  BodyId -> Ptr WorldTransform -> Float -> CBool -> IO ()
c_b2Body_SetTargetTransform BodyId
a0 Ptr WorldTransform
p1 Float
a2 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a3)

{- | Get the linear velocity of a local point attached to a body. Usually in meters per second.

Binds @b2Body_GetLocalPointVelocity@.
-}
getLocalPointVelocity
  :: BodyId
  -> Vec2
  -- ^ @localPoint@
  -> IO Vec2
getLocalPointVelocity :: BodyId -> Pos -> IO Pos
getLocalPointVelocity BodyId
a0 Pos
a1 =
  Pos -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> Ptr Pos -> IO ()
c_b2Body_GetLocalPointVelocity BodyId
a0 Ptr Pos
p1 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

{- | Get the linear velocity of a world point attached to a body. Usually in meters per second.

Binds @b2Body_GetWorldPointVelocity@.
-}
getWorldPointVelocity
  :: BodyId
  -> Pos
  -- ^ @worldPoint@
  -> IO Vec2
getWorldPointVelocity :: BodyId -> Pos -> IO Pos
getWorldPointVelocity BodyId
a0 Pos
a1 =
  Pos -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> Ptr Pos -> IO ()
c_b2Body_GetWorldPointVelocity BodyId
a0 Ptr Pos
p1 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

{- | Apply a force at a world point. If the force is not applied at the center of mass,
it will generate a torque and affect the angular velocity. This optionally wakes up the body.
The force is ignored if the body is not awake.

Binds @b2Body_ApplyForce@.
-}
applyForce
  :: BodyId
  -- ^ @bodyId@: The body id
  -> Vec2
  -- ^ @force@: The world force vector, usually in newtons (N)
  -> Pos
  -- ^ @point@: The world position of the point of application
  -> Bool
  -- ^ @wake@: Option to wake up the body
  -> IO ()
applyForce :: BodyId -> Pos -> Pos -> Bool -> IO ()
applyForce BodyId
a0 Pos
a1 Pos
a2 Bool
a3 =
  Pos -> (Ptr Pos -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO ()) -> IO ()) -> (Ptr Pos -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  Pos -> (Ptr Pos -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a2 ((Ptr Pos -> IO ()) -> IO ()) -> (Ptr Pos -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p2 ->
  BodyId -> Ptr Pos -> Ptr Pos -> CBool -> IO ()
c_b2Body_ApplyForce BodyId
a0 Ptr Pos
p1 Ptr Pos
p2 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a3)

{- | Apply a force to the center of mass. This optionally wakes up the body.
The force is ignored if the body is not awake.

Binds @b2Body_ApplyForceToCenter@.
-}
applyForceToCenter
  :: BodyId
  -- ^ @bodyId@: The body id
  -> Vec2
  -- ^ @force@: the world force vector, usually in newtons (N).
  -> Bool
  -- ^ @wake@: also wake up the body
  -> IO ()
applyForceToCenter :: BodyId -> Pos -> Bool -> IO ()
applyForceToCenter BodyId
a0 Pos
a1 Bool
a2 =
  Pos -> (Ptr Pos -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO ()) -> IO ()) -> (Ptr Pos -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  BodyId -> Ptr Pos -> CBool -> IO ()
c_b2Body_ApplyForceToCenter BodyId
a0 Ptr Pos
p1 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a2)

{- | Apply a torque. This affects the angular velocity without affecting the linear velocity.
This optionally wakes the body. The torque is ignored if the body is not awake.

Binds @b2Body_ApplyTorque@.
-}
applyTorque
  :: BodyId
  -- ^ @bodyId@: The body id
  -> Float
  -- ^ @torque@: about the z-axis (out of the screen), usually in N*m.
  -> Bool
  -- ^ @wake@: also wake up the body
  -> IO ()
applyTorque :: BodyId -> Float -> Bool -> IO ()
applyTorque BodyId
a0 Float
a1 Bool
a2 =
  BodyId -> Float -> CBool -> IO ()
c_b2Body_ApplyTorque BodyId
a0 Float
a1 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a2)

{- | Clear the force and torque on this body. Forces and torques are automatically cleared after each world
step. So this only needs to be called if the application wants to remove the effect of previous
calls to apply forces and torques before the world step is called.

Binds @b2Body_ClearForces@.
-}
clearForces
  :: BodyId
  -- ^ @bodyId@: The body id
  -> IO ()
clearForces :: BodyId -> IO ()
clearForces BodyId
a0 =
  BodyId -> IO ()
c_b2Body_ClearForces BodyId
a0

{- | Apply an impulse at a point. This immediately modifies the velocity.
It also modifies the angular velocity if the point of application
is not at the center of mass. This optionally wakes the body.
The impulse is ignored if the body is not awake.
Warning: This should be used for one-shot impulses. If you need a steady force,
use a force instead, which will work better with the sub-stepping solver.

Binds @b2Body_ApplyLinearImpulse@.
-}
applyLinearImpulse
  :: BodyId
  -- ^ @bodyId@: The body id
  -> Vec2
  -- ^ @impulse@: the world impulse vector, usually in N*s or kg*m\/s.
  -> Pos
  -- ^ @point@: the world position of the point of application.
  -> Bool
  -- ^ @wake@: also wake up the body
  -> IO ()
applyLinearImpulse :: BodyId -> Pos -> Pos -> Bool -> IO ()
applyLinearImpulse BodyId
a0 Pos
a1 Pos
a2 Bool
a3 =
  Pos -> (Ptr Pos -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO ()) -> IO ()) -> (Ptr Pos -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  Pos -> (Ptr Pos -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a2 ((Ptr Pos -> IO ()) -> IO ()) -> (Ptr Pos -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p2 ->
  BodyId -> Ptr Pos -> Ptr Pos -> CBool -> IO ()
c_b2Body_ApplyLinearImpulse BodyId
a0 Ptr Pos
p1 Ptr Pos
p2 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a3)

{- | Apply an impulse to the center of mass. This immediately modifies the velocity.
The impulse is ignored if the body is not awake. This optionally wakes the body.
Warning: This should be used for one-shot impulses. If you need a steady force,
use a force instead, which will work better with the sub-stepping solver.

Binds @b2Body_ApplyLinearImpulseToCenter@.
-}
applyLinearImpulseToCenter
  :: BodyId
  -- ^ @bodyId@: The body id
  -> Vec2
  -- ^ @impulse@: the world impulse vector, usually in N*s or kg*m\/s.
  -> Bool
  -- ^ @wake@: also wake up the body
  -> IO ()
applyLinearImpulseToCenter :: BodyId -> Pos -> Bool -> IO ()
applyLinearImpulseToCenter BodyId
a0 Pos
a1 Bool
a2 =
  Pos -> (Ptr Pos -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Pos
a1 ((Ptr Pos -> IO ()) -> IO ()) -> (Ptr Pos -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
p1 ->
  BodyId -> Ptr Pos -> CBool -> IO ()
c_b2Body_ApplyLinearImpulseToCenter BodyId
a0 Ptr Pos
p1 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a2)

{- | Apply an angular impulse. The impulse is ignored if the body is not awake.
This optionally wakes the body.
Warning: This should be used for one-shot impulses. If you need a steady torque,
use a torque instead, which will work better with the sub-stepping solver.

Binds @b2Body_ApplyAngularImpulse@.
-}
applyAngularImpulse
  :: BodyId
  -- ^ @bodyId@: The body id
  -> Float
  -- ^ @impulse@: the angular impulse, usually in units of kg*m*m\/s
  -> Bool
  -- ^ @wake@: also wake up the body
  -> IO ()
applyAngularImpulse :: BodyId -> Float -> Bool -> IO ()
applyAngularImpulse BodyId
a0 Float
a1 Bool
a2 =
  BodyId -> Float -> CBool -> IO ()
c_b2Body_ApplyAngularImpulse BodyId
a0 Float
a1 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a2)

{- | Get the mass of the body, usually in kilograms

Binds @b2Body_GetMass@.
-}
getMass
  :: BodyId
  -> IO Float
getMass :: BodyId -> IO Float
getMass BodyId
a0 =
  BodyId -> IO Float
c_b2Body_GetMass BodyId
a0

{- | Get the rotational inertia of the body, usually in kg*m^2

Binds @b2Body_GetRotationalInertia@.
-}
getRotationalInertia
  :: BodyId
  -> IO Float
getRotationalInertia :: BodyId -> IO Float
getRotationalInertia BodyId
a0 =
  BodyId -> IO Float
c_b2Body_GetRotationalInertia BodyId
a0

{- | Get the center of mass position of the body in local space.

Binds @b2Body_GetLocalCenter@.
-}
getLocalCenter
  :: BodyId
  -> IO Vec2
getLocalCenter :: BodyId -> IO Pos
getLocalCenter BodyId
a0 =
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> IO ()
c_b2Body_GetLocalCenter BodyId
a0 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

-- | Like 'getLocalCenter', but the result is written into a caller-supplied buffer.
getLocalCenterInto
  :: BodyId
  -> Ptr Vec2
  -- ^ Result buffer.
  -> IO ()
getLocalCenterInto :: BodyId -> Ptr Pos -> IO ()
getLocalCenterInto BodyId
a0 Ptr Pos
out =
  BodyId -> Ptr Pos -> IO ()
c_b2Body_GetLocalCenter BodyId
a0 Ptr Pos
out

{- | Get the center of mass position of the body in world space.

Binds @b2Body_GetWorldCenter@.
-}
getWorldCenter
  :: BodyId
  -> IO Pos
getWorldCenter :: BodyId -> IO Pos
getWorldCenter BodyId
a0 =
  (Ptr Pos -> IO Pos) -> IO Pos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Pos -> IO Pos) -> IO Pos) -> (Ptr Pos -> IO Pos) -> IO Pos
forall a b. (a -> b) -> a -> b
$ \Ptr Pos
pOut -> BodyId -> Ptr Pos -> IO ()
c_b2Body_GetWorldCenter BodyId
a0 Ptr Pos
pOut IO () -> IO Pos -> IO Pos
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Pos -> IO Pos
forall a. Storable a => Ptr a -> IO a
peek Ptr Pos
pOut

-- | Like 'getWorldCenter', but the result is written into a caller-supplied buffer.
getWorldCenterInto
  :: BodyId
  -> Ptr Pos
  -- ^ Result buffer.
  -> IO ()
getWorldCenterInto :: BodyId -> Ptr Pos -> IO ()
getWorldCenterInto BodyId
a0 Ptr Pos
out =
  BodyId -> Ptr Pos -> IO ()
c_b2Body_GetWorldCenter BodyId
a0 Ptr Pos
out

{- | Override the body\'s mass properties. Normally this is computed automatically using the
shape geometry and density. This information is lost if a shape is added or removed or if the
body type changes.

Binds @b2Body_SetMassData@.
-}
setMassData
  :: BodyId
  -> MassData
  -> IO ()
setMassData :: BodyId -> MassData -> IO ()
setMassData BodyId
a0 MassData
a1 =
  MassData -> (Ptr MassData -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with MassData
a1 ((Ptr MassData -> IO ()) -> IO ())
-> (Ptr MassData -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MassData
p1 ->
  BodyId -> Ptr MassData -> IO ()
c_b2Body_SetMassData BodyId
a0 Ptr MassData
p1

{- | Get the mass data for a body

Binds @b2Body_GetMassData@.
-}
getMassData
  :: BodyId
  -> IO MassData
getMassData :: BodyId -> IO MassData
getMassData BodyId
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 -> BodyId -> Ptr MassData -> IO ()
c_b2Body_GetMassData BodyId
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 'getMassData', but the result is written into a caller-supplied buffer.
getMassDataInto
  :: BodyId
  -> Ptr MassData
  -- ^ Result buffer.
  -> IO ()
getMassDataInto :: BodyId -> Ptr MassData -> IO ()
getMassDataInto BodyId
a0 Ptr MassData
out =
  BodyId -> Ptr MassData -> IO ()
c_b2Body_GetMassData BodyId
a0 Ptr MassData
out

{- | This updates the mass properties to the sum of the mass properties of the shapes.
This normally does not need to be called unless you called SetMassData to override
the mass and you later want to reset the mass.
You may also use this when automatic mass computation has been disabled.
You should call this regardless of body type.
Note that sensor shapes may have mass.

Binds @b2Body_ApplyMassFromShapes@.
-}
applyMassFromShapes
  :: BodyId
  -> IO ()
applyMassFromShapes :: BodyId -> IO ()
applyMassFromShapes BodyId
a0 =
  BodyId -> IO ()
c_b2Body_ApplyMassFromShapes BodyId
a0

{- | Adjust the linear damping. Normally this is set in b2BodyDef before creation.

Binds @b2Body_SetLinearDamping@.
-}
setLinearDamping
  :: BodyId
  -> Float
  -- ^ @linearDamping@
  -> IO ()
setLinearDamping :: BodyId -> Float -> IO ()
setLinearDamping BodyId
a0 Float
a1 =
  BodyId -> Float -> IO ()
c_b2Body_SetLinearDamping BodyId
a0 Float
a1

{- | Get the current linear damping.

Binds @b2Body_GetLinearDamping@.
-}
getLinearDamping
  :: BodyId
  -> IO Float
getLinearDamping :: BodyId -> IO Float
getLinearDamping BodyId
a0 =
  BodyId -> IO Float
c_b2Body_GetLinearDamping BodyId
a0

{- | Adjust the angular damping. Normally this is set in b2BodyDef before creation.

Binds @b2Body_SetAngularDamping@.
-}
setAngularDamping
  :: BodyId
  -> Float
  -- ^ @angularDamping@
  -> IO ()
setAngularDamping :: BodyId -> Float -> IO ()
setAngularDamping BodyId
a0 Float
a1 =
  BodyId -> Float -> IO ()
c_b2Body_SetAngularDamping BodyId
a0 Float
a1

{- | Get the current angular damping.

Binds @b2Body_GetAngularDamping@.
-}
getAngularDamping
  :: BodyId
  -> IO Float
getAngularDamping :: BodyId -> IO Float
getAngularDamping BodyId
a0 =
  BodyId -> IO Float
c_b2Body_GetAngularDamping BodyId
a0

{- | Adjust the gravity scale. Normally this is set in b2BodyDef before creation.
See also b2BodyDef::gravityScale.

Binds @b2Body_SetGravityScale@.
-}
setGravityScale
  :: BodyId
  -> Float
  -- ^ @gravityScale@
  -> IO ()
setGravityScale :: BodyId -> Float -> IO ()
setGravityScale BodyId
a0 Float
a1 =
  BodyId -> Float -> IO ()
c_b2Body_SetGravityScale BodyId
a0 Float
a1

{- | Get the current gravity scale

Binds @b2Body_GetGravityScale@.
-}
getGravityScale
  :: BodyId
  -> IO Float
getGravityScale :: BodyId -> IO Float
getGravityScale BodyId
a0 =
  BodyId -> IO Float
c_b2Body_GetGravityScale BodyId
a0

{- | Returns: true if this body is awake

Binds @b2Body_IsAwake@.
-}
isAwake
  :: BodyId
  -> IO Bool
isAwake :: BodyId -> IO Bool
isAwake BodyId
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
<$> (BodyId -> IO CBool
c_b2Body_IsAwake BodyId
a0)

{- | Wake a body from sleep. This wakes the entire island the body is touching.
Warning: Putting a body to sleep will put the entire island of bodies touching this body to sleep,
which can be expensive and possibly unintuitive.

Binds @b2Body_SetAwake@.
-}
setAwake
  :: BodyId
  -> Bool
  -- ^ @awake@
  -> IO ()
setAwake :: BodyId -> Bool -> IO ()
setAwake BodyId
a0 Bool
a1 =
  BodyId -> CBool -> IO ()
c_b2Body_SetAwake BodyId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Wake bodies touching this body. Works for static bodies.

Binds @b2Body_WakeTouching@.
-}
wakeTouching
  :: BodyId
  -> IO ()
wakeTouching :: BodyId -> IO ()
wakeTouching BodyId
a0 =
  BodyId -> IO ()
c_b2Body_WakeTouching BodyId
a0

{- | Enable or disable sleeping for this body. If sleeping is disabled the body will wake (and the entire island).

Binds @b2Body_EnableSleep@.
-}
enableSleep
  :: BodyId
  -> Bool
  -- ^ @enableSleep@
  -> IO ()
enableSleep :: BodyId -> Bool -> IO ()
enableSleep BodyId
a0 Bool
a1 =
  BodyId -> CBool -> IO ()
c_b2Body_EnableSleep BodyId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Returns true if sleeping is enabled for this body

Binds @b2Body_IsSleepEnabled@.
-}
isSleepEnabled
  :: BodyId
  -> IO Bool
isSleepEnabled :: BodyId -> IO Bool
isSleepEnabled BodyId
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
<$> (BodyId -> IO CBool
c_b2Body_IsSleepEnabled BodyId
a0)

{- | Set the sleep threshold, usually in meters per second

Binds @b2Body_SetSleepThreshold@.
-}
setSleepThreshold
  :: BodyId
  -> Float
  -- ^ @sleepThreshold@
  -> IO ()
setSleepThreshold :: BodyId -> Float -> IO ()
setSleepThreshold BodyId
a0 Float
a1 =
  BodyId -> Float -> IO ()
c_b2Body_SetSleepThreshold BodyId
a0 Float
a1

{- | Get the sleep threshold, usually in meters per second.

Binds @b2Body_GetSleepThreshold@.
-}
getSleepThreshold
  :: BodyId
  -> IO Float
getSleepThreshold :: BodyId -> IO Float
getSleepThreshold BodyId
a0 =
  BodyId -> IO Float
c_b2Body_GetSleepThreshold BodyId
a0

{- | Returns true if this body is enabled

Binds @b2Body_IsEnabled@.
-}
isEnabled
  :: BodyId
  -> IO Bool
isEnabled :: BodyId -> IO Bool
isEnabled BodyId
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
<$> (BodyId -> IO CBool
c_b2Body_IsEnabled BodyId
a0)

{- | Disable a body by removing it completely from the simulation. This is expensive.

Binds @b2Body_Disable@.
-}
disable
  :: BodyId
  -> IO ()
disable :: BodyId -> IO ()
disable BodyId
a0 =
  BodyId -> IO ()
c_b2Body_Disable BodyId
a0

{- | Enable a body by adding it to the simulation. This is expensive.

Binds @b2Body_Enable@.
-}
enable
  :: BodyId
  -> IO ()
enable :: BodyId -> IO ()
enable BodyId
a0 =
  BodyId -> IO ()
c_b2Body_Enable BodyId
a0

{- | Set the motion locks on this body.

Binds @b2Body_SetMotionLocks@.
-}
setMotionLocks
  :: BodyId
  -> MotionLocks
  -> IO ()
setMotionLocks :: BodyId -> MotionLocks -> IO ()
setMotionLocks BodyId
a0 MotionLocks
a1 =
  MotionLocks -> (Ptr MotionLocks -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with MotionLocks
a1 ((Ptr MotionLocks -> IO ()) -> IO ())
-> (Ptr MotionLocks -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MotionLocks
p1 ->
  BodyId -> Ptr MotionLocks -> IO ()
c_b2Body_SetMotionLocks BodyId
a0 Ptr MotionLocks
p1

{- | Get the motion locks for this body.

Binds @b2Body_GetMotionLocks@.
-}
getMotionLocks
  :: BodyId
  -> IO MotionLocks
getMotionLocks :: BodyId -> IO MotionLocks
getMotionLocks BodyId
a0 =
  (Ptr MotionLocks -> IO MotionLocks) -> IO MotionLocks
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr MotionLocks -> IO MotionLocks) -> IO MotionLocks)
-> (Ptr MotionLocks -> IO MotionLocks) -> IO MotionLocks
forall a b. (a -> b) -> a -> b
$ \Ptr MotionLocks
pOut -> BodyId -> Ptr MotionLocks -> IO ()
c_b2Body_GetMotionLocks BodyId
a0 Ptr MotionLocks
pOut IO () -> IO MotionLocks -> IO MotionLocks
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr MotionLocks -> IO MotionLocks
forall a. Storable a => Ptr a -> IO a
peek Ptr MotionLocks
pOut

-- | Like 'getMotionLocks', but the result is written into a caller-supplied buffer.
getMotionLocksInto
  :: BodyId
  -> Ptr MotionLocks
  -- ^ Result buffer.
  -> IO ()
getMotionLocksInto :: BodyId -> Ptr MotionLocks -> IO ()
getMotionLocksInto BodyId
a0 Ptr MotionLocks
out =
  BodyId -> Ptr MotionLocks -> IO ()
c_b2Body_GetMotionLocks BodyId
a0 Ptr MotionLocks
out

{- | Set this body to be a bullet. A bullet does continuous collision detection
against dynamic bodies (but not other bullets).

Binds @b2Body_SetBullet@.
-}
setBullet
  :: BodyId
  -> Bool
  -- ^ @flag@
  -> IO ()
setBullet :: BodyId -> Bool -> IO ()
setBullet BodyId
a0 Bool
a1 =
  BodyId -> CBool -> IO ()
c_b2Body_SetBullet BodyId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Is this body a bullet?

Binds @b2Body_IsBullet@.
-}
isBullet
  :: BodyId
  -> IO Bool
isBullet :: BodyId -> IO Bool
isBullet BodyId
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
<$> (BodyId -> IO CBool
c_b2Body_IsBullet BodyId
a0)

{- | Enable or disable contact recycling for this body. Contact recycling is a performance optimization
that reuses contact manifolds when bodies move slightly. Disabling it can avoid ghost collisions
on characters at the cost of higher per-step work. Existing contacts retain their prior setting;
only contacts created after this call see the new value.
See also b2BodyDef::enableContactRecycling.

Binds @b2Body_EnableContactRecycling@.
-}
enableContactRecycling
  :: BodyId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableContactRecycling :: BodyId -> Bool -> IO ()
enableContactRecycling BodyId
a0 Bool
a1 =
  BodyId -> CBool -> IO ()
c_b2Body_EnableContactRecycling BodyId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Is contact recycling enabled on this body?

Binds @b2Body_IsContactRecyclingEnabled@.
-}
isContactRecyclingEnabled
  :: BodyId
  -> IO Bool
isContactRecyclingEnabled :: BodyId -> IO Bool
isContactRecyclingEnabled BodyId
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
<$> (BodyId -> IO CBool
c_b2Body_IsContactRecyclingEnabled BodyId
a0)

{- | Enable\/disable contact events on all shapes.
See also b2ShapeDef::enableContactEvents.
Warning: changing this at runtime may cause mismatched begin\/end touch events

Binds @b2Body_EnableContactEvents@.
-}
enableContactEvents
  :: BodyId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableContactEvents :: BodyId -> Bool -> IO ()
enableContactEvents BodyId
a0 Bool
a1 =
  BodyId -> CBool -> IO ()
c_b2Body_EnableContactEvents BodyId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Enable\/disable hit events on all shapes
See also b2ShapeDef::enableHitEvents.

Binds @b2Body_EnableHitEvents@.
-}
enableHitEvents
  :: BodyId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableHitEvents :: BodyId -> Bool -> IO ()
enableHitEvents BodyId
a0 Bool
a1 =
  BodyId -> CBool -> IO ()
c_b2Body_EnableHitEvents BodyId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Get the world that owns this body

Binds @b2Body_GetWorld@.
-}
getWorld
  :: BodyId
  -> IO WorldId
getWorld :: BodyId -> IO WorldId
getWorld BodyId
a0 =
  BodyId -> IO WorldId
c_b2Body_GetWorld BodyId
a0

{- | Get the number of shapes on this body

Binds @b2Body_GetShapeCount@.
-}
getShapeCount
  :: BodyId
  -> IO Int
getShapeCount :: BodyId -> IO Int
getShapeCount BodyId
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
<$> (BodyId -> IO CInt
c_b2Body_GetShapeCount BodyId
a0)

{- | Get the shape ids for all shapes on this body, up to the provided capacity.

Returns: the number of shape ids stored in the user array

Binds @b2Body_GetShapes@.
-}
getShapes
  :: BodyId
  -> Ptr ShapeId
  -- ^ @shapeArray@
  -> Int
  -- ^ @capacity@
  -> IO Int
getShapes :: BodyId -> Ptr ShapeId -> Int -> IO Int
getShapes BodyId
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
<$> (BodyId -> Ptr ShapeId -> CInt -> IO CInt
c_b2Body_GetShapes BodyId
a0 Ptr ShapeId
a1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2))

{- | Get the number of joints on this body

Binds @b2Body_GetJointCount@.
-}
getJointCount
  :: BodyId
  -> IO Int
getJointCount :: BodyId -> IO Int
getJointCount BodyId
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
<$> (BodyId -> IO CInt
c_b2Body_GetJointCount BodyId
a0)

{- | Get the joint ids for all joints on this body, up to the provided capacity

Returns: the number of joint ids stored in the user array

Binds @b2Body_GetJoints@.
-}
getJoints
  :: BodyId
  -> Ptr JointId
  -- ^ @jointArray@
  -> Int
  -- ^ @capacity@
  -> IO Int
getJoints :: BodyId -> Ptr JointId -> Int -> IO Int
getJoints BodyId
a0 Ptr JointId
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
<$> (BodyId -> Ptr JointId -> CInt -> IO CInt
c_b2Body_GetJoints BodyId
a0 Ptr JointId
a1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2))

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

Binds @b2Body_GetContactCapacity@.
-}
getContactCapacity
  :: BodyId
  -> IO Int
getContactCapacity :: BodyId -> IO Int
getContactCapacity BodyId
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
<$> (BodyId -> IO CInt
c_b2Body_GetContactCapacity BodyId
a0)

{- | Get the touching contact data for a body.
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 @b2Body_GetContactData@.
-}
getContactData
  :: BodyId
  -> Ptr ContactData
  -> Int
  -- ^ @capacity@
  -> IO Int
getContactData :: BodyId -> Ptr ContactData -> Int -> IO Int
getContactData BodyId
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
<$> (BodyId -> Ptr ContactData -> CInt -> IO CInt
c_b2Body_GetContactData BodyId
a0 Ptr ContactData
a1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2))

{- | Get the current world AABB that contains all the attached shapes. Note that this may not encompass the body origin.
If there are no shapes attached then the returned AABB is empty and centered on the body origin.

Binds @b2Body_ComputeAABB@.
-}
computeAABB
  :: BodyId
  -> IO AABB
computeAABB :: BodyId -> IO AABB
computeAABB BodyId
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 -> BodyId -> Ptr AABB -> IO ()
c_b2Body_ComputeAABB BodyId
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 'computeAABB', but the result is written into a caller-supplied buffer.
computeAABBInto
  :: BodyId
  -> Ptr AABB
  -- ^ Result buffer.
  -> IO ()
computeAABBInto :: BodyId -> Ptr AABB -> IO ()
computeAABBInto BodyId
a0 Ptr AABB
out =
  BodyId -> Ptr AABB -> IO ()
c_b2Body_ComputeAABB BodyId
a0 Ptr AABB
out