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

module Box2D.World
  ( create
  , destroy
  , isValid
  , step
  , draw
  , getBounds
  , getBoundsInto
  , getBodyEvents
  , getBodyEventsInto
  , getSensorEvents
  , getSensorEventsInto
  , getContactEvents
  , getContactEventsInto
  , getJointEvents
  , getJointEventsInto
  , overlapAABB
  , overlapShape
  , castRay
  , castRayClosest
  , castShape
  , castMover
  , collideMover
  , enableSleeping
  , isSleepingEnabled
  , enableContinuous
  , isContinuousEnabled
  , setRestitutionThreshold
  , getRestitutionThreshold
  , setHitEventThreshold
  , getHitEventThreshold
  , setCustomFilterCallback
  , setPreSolveCallback
  , setGravity
  , getGravity
  , getGravityInto
  , explode
  , setContactTuning
  , setContactRecycleDistance
  , getContactRecycleDistance
  , setMaximumLinearSpeed
  , getMaximumLinearSpeed
  , enableWarmStarting
  , isWarmStartingEnabled
  , getAwakeBodyCount
  , getProfile
  , getCounters
  , getMaxCapacity
  , getMaxCapacityInto
  , setUserData
  , getUserData
  , setFrictionCallback
  , setRestitutionCallback
  , setWorkerCount
  , getWorkerCount
  , dumpMemoryStats
  , rebuildStaticTree
  , enableSpeculative
  , startRecording
  , stopRecording
  , snapshot
  , restore
  , createFromSnapshot
  )

  where

import Foreign
import Foreign.C.Types (CBool(..), CInt(..))
import Box2D.Id (WorldId(..))
import Box2D.MathTypes (AABB, Pos, Vec2)
import Box2D.Tags (CastResultFcn, Counters, CustomFilterFcn, DebugDraw, FrictionCallback, OverlapResultFcn, PlaneResultFcn, PreSolveFcn, Profile, Recording, RestitutionCallback, ShapeProxy)
import Box2D.Types (BodyEvents, Capacity, Capsule, ContactEvents, ExplosionDef, JointEvents, QueryFilter, RayResult, SensorEvents, TreeStats, WorldDef)

foreign import ccall unsafe "b2CreateWorld"
  c_b2CreateWorld :: Ptr WorldDef -> IO WorldId

foreign import ccall unsafe "b2DestroyWorld"
  c_b2DestroyWorld :: WorldId -> IO ()

foreign import ccall unsafe "b2World_IsValid"
  c_b2World_IsValid :: WorldId -> IO CBool

foreign import ccall safe "b2World_Step"
  c_b2World_Step :: WorldId -> Float -> CInt -> IO ()

foreign import ccall unsafe "b2World_Draw"
  c_b2World_Draw :: WorldId -> Ptr DebugDraw -> IO ()

foreign import ccall unsafe "hsg_b2World_GetBounds"
  c_b2World_GetBounds :: WorldId -> Ptr AABB -> IO ()

foreign import ccall unsafe "hsg_b2World_GetBodyEvents"
  c_b2World_GetBodyEvents :: WorldId -> Ptr BodyEvents -> IO ()

foreign import ccall unsafe "hsg_b2World_GetSensorEvents"
  c_b2World_GetSensorEvents :: WorldId -> Ptr SensorEvents -> IO ()

foreign import ccall unsafe "hsg_b2World_GetContactEvents"
  c_b2World_GetContactEvents :: WorldId -> Ptr ContactEvents -> IO ()

foreign import ccall unsafe "hsg_b2World_GetJointEvents"
  c_b2World_GetJointEvents :: WorldId -> Ptr JointEvents -> IO ()

foreign import ccall safe "hsg_b2World_OverlapAABB"
  c_b2World_OverlapAABB :: WorldId -> Ptr Pos -> Ptr AABB -> Ptr QueryFilter -> FunPtr OverlapResultFcn -> Ptr () -> Ptr TreeStats -> IO ()

foreign import ccall safe "hsg_b2World_OverlapShape"
  c_b2World_OverlapShape :: WorldId -> Ptr Pos -> Ptr ShapeProxy -> Ptr QueryFilter -> FunPtr OverlapResultFcn -> Ptr () -> Ptr TreeStats -> IO ()

foreign import ccall safe "hsg_b2World_CastRay"
  c_b2World_CastRay :: WorldId -> Ptr Pos -> Ptr Vec2 -> Ptr QueryFilter -> FunPtr CastResultFcn -> Ptr () -> Ptr TreeStats -> IO ()

foreign import ccall unsafe "hsg_b2World_CastRayClosest"
  c_b2World_CastRayClosest :: WorldId -> Ptr Pos -> Ptr Vec2 -> Ptr QueryFilter -> Ptr RayResult -> IO ()

foreign import ccall safe "hsg_b2World_CastShape"
  c_b2World_CastShape :: WorldId -> Ptr Pos -> Ptr ShapeProxy -> Ptr Vec2 -> Ptr QueryFilter -> FunPtr CastResultFcn -> Ptr () -> Ptr TreeStats -> IO ()

foreign import ccall unsafe "hsg_b2World_CastMover"
  c_b2World_CastMover :: WorldId -> Ptr Pos -> Ptr Capsule -> Ptr Vec2 -> Ptr QueryFilter -> IO Float

foreign import ccall safe "hsg_b2World_CollideMover"
  c_b2World_CollideMover :: WorldId -> Ptr Pos -> Ptr Capsule -> Ptr QueryFilter -> FunPtr PlaneResultFcn -> Ptr () -> IO ()

foreign import ccall unsafe "b2World_EnableSleeping"
  c_b2World_EnableSleeping :: WorldId -> CBool -> IO ()

foreign import ccall unsafe "b2World_IsSleepingEnabled"
  c_b2World_IsSleepingEnabled :: WorldId -> IO CBool

foreign import ccall unsafe "b2World_EnableContinuous"
  c_b2World_EnableContinuous :: WorldId -> CBool -> IO ()

foreign import ccall unsafe "b2World_IsContinuousEnabled"
  c_b2World_IsContinuousEnabled :: WorldId -> IO CBool

foreign import ccall unsafe "b2World_SetRestitutionThreshold"
  c_b2World_SetRestitutionThreshold :: WorldId -> Float -> IO ()

foreign import ccall unsafe "b2World_GetRestitutionThreshold"
  c_b2World_GetRestitutionThreshold :: WorldId -> IO Float

foreign import ccall unsafe "b2World_SetHitEventThreshold"
  c_b2World_SetHitEventThreshold :: WorldId -> Float -> IO ()

foreign import ccall unsafe "b2World_GetHitEventThreshold"
  c_b2World_GetHitEventThreshold :: WorldId -> IO Float

foreign import ccall safe "b2World_SetCustomFilterCallback"
  c_b2World_SetCustomFilterCallback :: WorldId -> FunPtr CustomFilterFcn -> Ptr () -> IO ()

foreign import ccall safe "b2World_SetPreSolveCallback"
  c_b2World_SetPreSolveCallback :: WorldId -> FunPtr PreSolveFcn -> Ptr () -> IO ()

foreign import ccall unsafe "hsg_b2World_SetGravity"
  c_b2World_SetGravity :: WorldId -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "hsg_b2World_GetGravity"
  c_b2World_GetGravity :: WorldId -> Ptr Vec2 -> IO ()

foreign import ccall unsafe "b2World_Explode"
  c_b2World_Explode :: WorldId -> Ptr ExplosionDef -> IO ()

foreign import ccall unsafe "b2World_SetContactTuning"
  c_b2World_SetContactTuning :: WorldId -> Float -> Float -> Float -> IO ()

foreign import ccall unsafe "b2World_SetContactRecycleDistance"
  c_b2World_SetContactRecycleDistance :: WorldId -> Float -> IO ()

foreign import ccall unsafe "b2World_GetContactRecycleDistance"
  c_b2World_GetContactRecycleDistance :: WorldId -> IO Float

foreign import ccall unsafe "b2World_SetMaximumLinearSpeed"
  c_b2World_SetMaximumLinearSpeed :: WorldId -> Float -> IO ()

foreign import ccall unsafe "b2World_GetMaximumLinearSpeed"
  c_b2World_GetMaximumLinearSpeed :: WorldId -> IO Float

foreign import ccall unsafe "b2World_EnableWarmStarting"
  c_b2World_EnableWarmStarting :: WorldId -> CBool -> IO ()

foreign import ccall unsafe "b2World_IsWarmStartingEnabled"
  c_b2World_IsWarmStartingEnabled :: WorldId -> IO CBool

foreign import ccall unsafe "b2World_GetAwakeBodyCount"
  c_b2World_GetAwakeBodyCount :: WorldId -> IO CInt

foreign import ccall unsafe "hsg_b2World_GetProfile"
  c_b2World_GetProfile :: WorldId -> Ptr Profile -> IO ()

foreign import ccall unsafe "hsg_b2World_GetCounters"
  c_b2World_GetCounters :: WorldId -> Ptr Counters -> IO ()

foreign import ccall unsafe "hsg_b2World_GetMaxCapacity"
  c_b2World_GetMaxCapacity :: WorldId -> Ptr Capacity -> IO ()

foreign import ccall unsafe "b2World_SetUserData"
  c_b2World_SetUserData :: WorldId -> Ptr () -> IO ()

foreign import ccall unsafe "b2World_GetUserData"
  c_b2World_GetUserData :: WorldId -> IO (Ptr ())

foreign import ccall safe "b2World_SetFrictionCallback"
  c_b2World_SetFrictionCallback :: WorldId -> FunPtr FrictionCallback -> IO ()

foreign import ccall safe "b2World_SetRestitutionCallback"
  c_b2World_SetRestitutionCallback :: WorldId -> FunPtr RestitutionCallback -> IO ()

foreign import ccall unsafe "b2World_SetWorkerCount"
  c_b2World_SetWorkerCount :: WorldId -> CInt -> IO ()

foreign import ccall unsafe "b2World_GetWorkerCount"
  c_b2World_GetWorkerCount :: WorldId -> IO CInt

foreign import ccall unsafe "b2World_DumpMemoryStats"
  c_b2World_DumpMemoryStats :: WorldId -> IO ()

foreign import ccall unsafe "b2World_RebuildStaticTree"
  c_b2World_RebuildStaticTree :: WorldId -> IO ()

foreign import ccall unsafe "b2World_EnableSpeculative"
  c_b2World_EnableSpeculative :: WorldId -> CBool -> IO ()

foreign import ccall unsafe "b2World_StartRecording"
  c_b2World_StartRecording :: WorldId -> Ptr Recording -> IO ()

foreign import ccall unsafe "b2World_StopRecording"
  c_b2World_StopRecording :: WorldId -> IO ()

foreign import ccall unsafe "b2World_Snapshot"
  c_b2World_Snapshot :: WorldId -> Ptr Word8 -> CInt -> IO CInt

foreign import ccall unsafe "b2World_Restore"
  c_b2World_Restore :: WorldId -> Ptr Word8 -> CInt -> IO CBool

foreign import ccall unsafe "b2CreateWorldFromSnapshot"
  c_b2CreateWorldFromSnapshot :: Ptr Word8 -> CInt -> CInt -> IO WorldId

{- | Create a world for rigid body simulation. A world contains bodies, shapes, and constraints. You make create
up to 128 worlds. Each world is completely independent and may be simulated in parallel.

Returns: the world id.

Binds @b2CreateWorld@.
-}
create
  :: WorldDef
  -> IO WorldId
create :: WorldDef -> IO WorldId
create WorldDef
a0 =
  WorldDef -> (Ptr WorldDef -> IO WorldId) -> IO WorldId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with WorldDef
a0 ((Ptr WorldDef -> IO WorldId) -> IO WorldId)
-> (Ptr WorldDef -> IO WorldId) -> IO WorldId
forall a b. (a -> b) -> a -> b
$ \Ptr WorldDef
p0 ->
  Ptr WorldDef -> IO WorldId
c_b2CreateWorld Ptr WorldDef
p0

{- | Destroy a world

Binds @b2DestroyWorld@.
-}
destroy
  :: WorldId
  -> IO ()
destroy :: WorldId -> IO ()
destroy WorldId
a0 =
  WorldId -> IO ()
c_b2DestroyWorld WorldId
a0

{- | World id validation. Provides validation for up to 64K allocations.

Binds @b2World_IsValid@.
-}
isValid
  :: WorldId
  -> IO Bool
isValid :: WorldId -> IO Bool
isValid WorldId
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
<$> (WorldId -> IO CBool
c_b2World_IsValid WorldId
a0)

{- | Simulate a world for one time step. This performs collision detection, integration, and constraint solution.

Binds @b2World_Step@.
-}
step
  :: WorldId
  -- ^ @worldId@: The world to simulate
  -> Float
  -- ^ @timeStep@: The amount of time to simulate, this should be a fixed number. Usually 1\/60.
  -> Int
  -- ^ @subStepCount@: The number of sub-steps, increasing the sub-step count can increase accuracy. Usually 4.
  -> IO ()
step :: WorldId -> Float -> Int -> IO ()
step WorldId
a0 Float
a1 Int
a2 =
  WorldId -> Float -> CInt -> IO ()
c_b2World_Step WorldId
a0 Float
a1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2)

{- | Call this to draw shapes and other debug draw data

Binds @b2World_Draw@.
-}
draw
  :: WorldId
  -> Ptr DebugDraw
  -> IO ()
draw :: WorldId -> Ptr DebugDraw -> IO ()
draw WorldId
a0 Ptr DebugDraw
a1 =
  WorldId -> Ptr DebugDraw -> IO ()
c_b2World_Draw WorldId
a0 Ptr DebugDraw
a1

{- | Call this to get the world bounds based on the union of all shape bounds.

Binds @b2World_GetBounds@.
-}
getBounds
  :: WorldId
  -> IO AABB
getBounds :: WorldId -> IO AABB
getBounds WorldId
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 -> WorldId -> Ptr AABB -> IO ()
c_b2World_GetBounds WorldId
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 'getBounds', but the result is written into a caller-supplied buffer.
getBoundsInto
  :: WorldId
  -> Ptr AABB
  -- ^ Result buffer.
  -> IO ()
getBoundsInto :: WorldId -> Ptr AABB -> IO ()
getBoundsInto WorldId
a0 Ptr AABB
out =
  WorldId -> Ptr AABB -> IO ()
c_b2World_GetBounds WorldId
a0 Ptr AABB
out

{- | Get the body events for the current time step. The event data is transient. Do not store a reference to this data.

Binds @b2World_GetBodyEvents@.
-}
getBodyEvents
  :: WorldId
  -> IO BodyEvents
getBodyEvents :: WorldId -> IO BodyEvents
getBodyEvents WorldId
a0 =
  (Ptr BodyEvents -> IO BodyEvents) -> IO BodyEvents
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr BodyEvents -> IO BodyEvents) -> IO BodyEvents)
-> (Ptr BodyEvents -> IO BodyEvents) -> IO BodyEvents
forall a b. (a -> b) -> a -> b
$ \Ptr BodyEvents
pOut -> WorldId -> Ptr BodyEvents -> IO ()
c_b2World_GetBodyEvents WorldId
a0 Ptr BodyEvents
pOut IO () -> IO BodyEvents -> IO BodyEvents
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr BodyEvents -> IO BodyEvents
forall a. Storable a => Ptr a -> IO a
peek Ptr BodyEvents
pOut

-- | Like 'getBodyEvents', but the result is written into a caller-supplied buffer.
getBodyEventsInto
  :: WorldId
  -> Ptr BodyEvents
  -- ^ Result buffer.
  -> IO ()
getBodyEventsInto :: WorldId -> Ptr BodyEvents -> IO ()
getBodyEventsInto WorldId
a0 Ptr BodyEvents
out =
  WorldId -> Ptr BodyEvents -> IO ()
c_b2World_GetBodyEvents WorldId
a0 Ptr BodyEvents
out

{- | Get sensor events for the current time step. The event data is transient. Do not store a reference to this data.

Binds @b2World_GetSensorEvents@.
-}
getSensorEvents
  :: WorldId
  -> IO SensorEvents
getSensorEvents :: WorldId -> IO SensorEvents
getSensorEvents WorldId
a0 =
  (Ptr SensorEvents -> IO SensorEvents) -> IO SensorEvents
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr SensorEvents -> IO SensorEvents) -> IO SensorEvents)
-> (Ptr SensorEvents -> IO SensorEvents) -> IO SensorEvents
forall a b. (a -> b) -> a -> b
$ \Ptr SensorEvents
pOut -> WorldId -> Ptr SensorEvents -> IO ()
c_b2World_GetSensorEvents WorldId
a0 Ptr SensorEvents
pOut IO () -> IO SensorEvents -> IO SensorEvents
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr SensorEvents -> IO SensorEvents
forall a. Storable a => Ptr a -> IO a
peek Ptr SensorEvents
pOut

-- | Like 'getSensorEvents', but the result is written into a caller-supplied buffer.
getSensorEventsInto
  :: WorldId
  -> Ptr SensorEvents
  -- ^ Result buffer.
  -> IO ()
getSensorEventsInto :: WorldId -> Ptr SensorEvents -> IO ()
getSensorEventsInto WorldId
a0 Ptr SensorEvents
out =
  WorldId -> Ptr SensorEvents -> IO ()
c_b2World_GetSensorEvents WorldId
a0 Ptr SensorEvents
out

{- | Get contact events for this current time step. The event data is transient. Do not store a reference to this data.

Binds @b2World_GetContactEvents@.
-}
getContactEvents
  :: WorldId
  -> IO ContactEvents
getContactEvents :: WorldId -> IO ContactEvents
getContactEvents WorldId
a0 =
  (Ptr ContactEvents -> IO ContactEvents) -> IO ContactEvents
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr ContactEvents -> IO ContactEvents) -> IO ContactEvents)
-> (Ptr ContactEvents -> IO ContactEvents) -> IO ContactEvents
forall a b. (a -> b) -> a -> b
$ \Ptr ContactEvents
pOut -> WorldId -> Ptr ContactEvents -> IO ()
c_b2World_GetContactEvents WorldId
a0 Ptr ContactEvents
pOut IO () -> IO ContactEvents -> IO ContactEvents
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr ContactEvents -> IO ContactEvents
forall a. Storable a => Ptr a -> IO a
peek Ptr ContactEvents
pOut

-- | Like 'getContactEvents', but the result is written into a caller-supplied buffer.
getContactEventsInto
  :: WorldId
  -> Ptr ContactEvents
  -- ^ Result buffer.
  -> IO ()
getContactEventsInto :: WorldId -> Ptr ContactEvents -> IO ()
getContactEventsInto WorldId
a0 Ptr ContactEvents
out =
  WorldId -> Ptr ContactEvents -> IO ()
c_b2World_GetContactEvents WorldId
a0 Ptr ContactEvents
out

{- | Get the joint events for the current time step. The event data is transient. Do not store a reference to this data.

Binds @b2World_GetJointEvents@.
-}
getJointEvents
  :: WorldId
  -> IO JointEvents
getJointEvents :: WorldId -> IO JointEvents
getJointEvents WorldId
a0 =
  (Ptr JointEvents -> IO JointEvents) -> IO JointEvents
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr JointEvents -> IO JointEvents) -> IO JointEvents)
-> (Ptr JointEvents -> IO JointEvents) -> IO JointEvents
forall a b. (a -> b) -> a -> b
$ \Ptr JointEvents
pOut -> WorldId -> Ptr JointEvents -> IO ()
c_b2World_GetJointEvents WorldId
a0 Ptr JointEvents
pOut IO () -> IO JointEvents -> IO JointEvents
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr JointEvents -> IO JointEvents
forall a. Storable a => Ptr a -> IO a
peek Ptr JointEvents
pOut

-- | Like 'getJointEvents', but the result is written into a caller-supplied buffer.
getJointEventsInto
  :: WorldId
  -> Ptr JointEvents
  -- ^ Result buffer.
  -> IO ()
getJointEventsInto :: WorldId -> Ptr JointEvents -> IO ()
getJointEventsInto WorldId
a0 Ptr JointEvents
out =
  WorldId -> Ptr JointEvents -> IO ()
c_b2World_GetJointEvents WorldId
a0 Ptr JointEvents
out

{- | Overlap test for all shapes that *potentially* overlap the provided AABB.
The AABB is relative to the origin, which keeps the test precise far from the world origin
in large world mode. Near the origin pass b2Pos_zero and a world AABB.

Binds @b2World_OverlapAABB@.
-}
overlapAABB
  :: WorldId
  -> Pos
  -- ^ @origin@
  -> AABB
  -> QueryFilter
  -> FunPtr OverlapResultFcn
  -> Ptr ()
  -- ^ @context@
  -> IO TreeStats
overlapAABB :: WorldId
-> Vec2
-> AABB
-> QueryFilter
-> FunPtr OverlapResultFcn
-> Ptr ()
-> IO TreeStats
overlapAABB WorldId
a0 Vec2
a1 AABB
a2 QueryFilter
a3 FunPtr OverlapResultFcn
a4 Ptr ()
a5 =
  Vec2 -> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO TreeStats) -> IO TreeStats)
-> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  AABB -> (Ptr AABB -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with AABB
a2 ((Ptr AABB -> IO TreeStats) -> IO TreeStats)
-> (Ptr AABB -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr AABB
p2 ->
  QueryFilter -> (Ptr QueryFilter -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with QueryFilter
a3 ((Ptr QueryFilter -> IO TreeStats) -> IO TreeStats)
-> (Ptr QueryFilter -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr QueryFilter
p3 ->
  (Ptr TreeStats -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr TreeStats -> IO TreeStats) -> IO TreeStats)
-> (Ptr TreeStats -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr TreeStats
pOut -> WorldId
-> Ptr Vec2
-> Ptr AABB
-> Ptr QueryFilter
-> FunPtr OverlapResultFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2World_OverlapAABB WorldId
a0 Ptr Vec2
p1 Ptr AABB
p2 Ptr QueryFilter
p3 FunPtr OverlapResultFcn
a4 Ptr ()
a5 Ptr TreeStats
pOut IO () -> IO TreeStats -> IO TreeStats
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr TreeStats -> IO TreeStats
forall a. Storable a => Ptr a -> IO a
peek Ptr TreeStats
pOut

{- | Overlap test for all shapes that overlap the provided shape proxy.
The proxy points are relative to the origin. Near the origin pass b2Pos_zero and world points.

Binds @b2World_OverlapShape@.
-}
overlapShape
  :: WorldId
  -> Pos
  -- ^ @origin@
  -> Ptr ShapeProxy
  -> QueryFilter
  -> FunPtr OverlapResultFcn
  -> Ptr ()
  -- ^ @context@
  -> IO TreeStats
overlapShape :: WorldId
-> Vec2
-> Ptr ShapeProxy
-> QueryFilter
-> FunPtr OverlapResultFcn
-> Ptr ()
-> IO TreeStats
overlapShape WorldId
a0 Vec2
a1 Ptr ShapeProxy
a2 QueryFilter
a3 FunPtr OverlapResultFcn
a4 Ptr ()
a5 =
  Vec2 -> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO TreeStats) -> IO TreeStats)
-> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  QueryFilter -> (Ptr QueryFilter -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with QueryFilter
a3 ((Ptr QueryFilter -> IO TreeStats) -> IO TreeStats)
-> (Ptr QueryFilter -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr QueryFilter
p3 ->
  (Ptr TreeStats -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr TreeStats -> IO TreeStats) -> IO TreeStats)
-> (Ptr TreeStats -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr TreeStats
pOut -> WorldId
-> Ptr Vec2
-> Ptr ShapeProxy
-> Ptr QueryFilter
-> FunPtr OverlapResultFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2World_OverlapShape WorldId
a0 Ptr Vec2
p1 Ptr ShapeProxy
a2 Ptr QueryFilter
p3 FunPtr OverlapResultFcn
a4 Ptr ()
a5 Ptr TreeStats
pOut IO () -> IO TreeStats -> IO TreeStats
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr TreeStats -> IO TreeStats
forall a. Storable a => Ptr a -> IO a
peek Ptr TreeStats
pOut

{- | Cast a ray into the world to collect shapes in the path of the ray.
Your callback function controls whether you get the closest point, any point, or n-points.
Note: The callback function may receive shapes in any order

Returns: traversal performance counters

Binds @b2World_CastRay@.
-}
castRay
  :: WorldId
  -- ^ @worldId@: The world to cast the ray against
  -> Pos
  -- ^ @origin@: The start point of the ray
  -> Vec2
  -- ^ @translation@: The translation of the ray from the start point to the end point
  -> QueryFilter
  -- ^ @filter@: Contains bit flags to filter unwanted shapes from the results
  -> FunPtr CastResultFcn
  -- ^ @fcn@: A user implemented callback function
  -> Ptr ()
  -- ^ @context@: A user context that is passed along to the callback function
  -> IO TreeStats
castRay :: WorldId
-> Vec2
-> Vec2
-> QueryFilter
-> FunPtr CastResultFcn
-> Ptr ()
-> IO TreeStats
castRay WorldId
a0 Vec2
a1 Vec2
a2 QueryFilter
a3 FunPtr CastResultFcn
a4 Ptr ()
a5 =
  Vec2 -> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO TreeStats) -> IO TreeStats)
-> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  Vec2 -> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a2 ((Ptr Vec2 -> IO TreeStats) -> IO TreeStats)
-> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p2 ->
  QueryFilter -> (Ptr QueryFilter -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with QueryFilter
a3 ((Ptr QueryFilter -> IO TreeStats) -> IO TreeStats)
-> (Ptr QueryFilter -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr QueryFilter
p3 ->
  (Ptr TreeStats -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr TreeStats -> IO TreeStats) -> IO TreeStats)
-> (Ptr TreeStats -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr TreeStats
pOut -> WorldId
-> Ptr Vec2
-> Ptr Vec2
-> Ptr QueryFilter
-> FunPtr CastResultFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2World_CastRay WorldId
a0 Ptr Vec2
p1 Ptr Vec2
p2 Ptr QueryFilter
p3 FunPtr CastResultFcn
a4 Ptr ()
a5 Ptr TreeStats
pOut IO () -> IO TreeStats -> IO TreeStats
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr TreeStats -> IO TreeStats
forall a. Storable a => Ptr a -> IO a
peek Ptr TreeStats
pOut

{- | Cast a ray into the world to collect the closest hit. This is a convenience function. Ignores initial overlap.
This is less general than b2World_CastRay() and does not allow for custom filtering.

Binds @b2World_CastRayClosest@.
-}
castRayClosest
  :: WorldId
  -> Pos
  -- ^ @origin@
  -> Vec2
  -- ^ @translation@
  -> QueryFilter
  -> IO RayResult
castRayClosest :: WorldId -> Vec2 -> Vec2 -> QueryFilter -> IO RayResult
castRayClosest WorldId
a0 Vec2
a1 Vec2
a2 QueryFilter
a3 =
  Vec2 -> (Ptr Vec2 -> IO RayResult) -> IO RayResult
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO RayResult) -> IO RayResult)
-> (Ptr Vec2 -> IO RayResult) -> IO RayResult
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  Vec2 -> (Ptr Vec2 -> IO RayResult) -> IO RayResult
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a2 ((Ptr Vec2 -> IO RayResult) -> IO RayResult)
-> (Ptr Vec2 -> IO RayResult) -> IO RayResult
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p2 ->
  QueryFilter -> (Ptr QueryFilter -> IO RayResult) -> IO RayResult
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with QueryFilter
a3 ((Ptr QueryFilter -> IO RayResult) -> IO RayResult)
-> (Ptr QueryFilter -> IO RayResult) -> IO RayResult
forall a b. (a -> b) -> a -> b
$ \Ptr QueryFilter
p3 ->
  (Ptr RayResult -> IO RayResult) -> IO RayResult
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr RayResult -> IO RayResult) -> IO RayResult)
-> (Ptr RayResult -> IO RayResult) -> IO RayResult
forall a b. (a -> b) -> a -> b
$ \Ptr RayResult
pOut -> WorldId
-> Ptr Vec2
-> Ptr Vec2
-> Ptr QueryFilter
-> Ptr RayResult
-> IO ()
c_b2World_CastRayClosest WorldId
a0 Ptr Vec2
p1 Ptr Vec2
p2 Ptr QueryFilter
p3 Ptr RayResult
pOut IO () -> IO RayResult -> IO RayResult
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr RayResult -> IO RayResult
forall a. Storable a => Ptr a -> IO a
peek Ptr RayResult
pOut

{- | Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.
The proxy points are relative to the origin. Callback points are world positions.
See also b2World_CastRay.

Binds @b2World_CastShape@.
-}
castShape
  :: WorldId
  -> Pos
  -- ^ @origin@
  -> Ptr ShapeProxy
  -> Vec2
  -- ^ @translation@
  -> QueryFilter
  -> FunPtr CastResultFcn
  -> Ptr ()
  -- ^ @context@
  -> IO TreeStats
castShape :: WorldId
-> Vec2
-> Ptr ShapeProxy
-> Vec2
-> QueryFilter
-> FunPtr CastResultFcn
-> Ptr ()
-> IO TreeStats
castShape WorldId
a0 Vec2
a1 Ptr ShapeProxy
a2 Vec2
a3 QueryFilter
a4 FunPtr CastResultFcn
a5 Ptr ()
a6 =
  Vec2 -> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO TreeStats) -> IO TreeStats)
-> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  Vec2 -> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a3 ((Ptr Vec2 -> IO TreeStats) -> IO TreeStats)
-> (Ptr Vec2 -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p3 ->
  QueryFilter -> (Ptr QueryFilter -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with QueryFilter
a4 ((Ptr QueryFilter -> IO TreeStats) -> IO TreeStats)
-> (Ptr QueryFilter -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr QueryFilter
p4 ->
  (Ptr TreeStats -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr TreeStats -> IO TreeStats) -> IO TreeStats)
-> (Ptr TreeStats -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr TreeStats
pOut -> WorldId
-> Ptr Vec2
-> Ptr ShapeProxy
-> Ptr Vec2
-> Ptr QueryFilter
-> FunPtr CastResultFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2World_CastShape WorldId
a0 Ptr Vec2
p1 Ptr ShapeProxy
a2 Ptr Vec2
p3 Ptr QueryFilter
p4 FunPtr CastResultFcn
a5 Ptr ()
a6 Ptr TreeStats
pOut IO () -> IO TreeStats -> IO TreeStats
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr TreeStats -> IO TreeStats
forall a. Storable a => Ptr a -> IO a
peek Ptr TreeStats
pOut

{- | Cast a capsule mover through the world. This is a special shape cast that handles sliding along other shapes while reducing
clipping. The mover capsule is relative to the origin. Near the origin pass b2Pos_zero and a world capsule.

Binds @b2World_CastMover@.
-}
castMover
  :: WorldId
  -> Pos
  -- ^ @origin@
  -> Capsule
  -- ^ @mover@
  -> Vec2
  -- ^ @translation@
  -> QueryFilter
  -> IO Float
castMover :: WorldId -> Vec2 -> Capsule -> Vec2 -> QueryFilter -> IO Float
castMover WorldId
a0 Vec2
a1 Capsule
a2 Vec2
a3 QueryFilter
a4 =
  Vec2 -> (Ptr Vec2 -> IO Float) -> IO Float
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a1 ((Ptr Vec2 -> IO Float) -> IO Float)
-> (Ptr Vec2 -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p1 ->
  Capsule -> (Ptr Capsule -> IO Float) -> IO Float
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Capsule
a2 ((Ptr Capsule -> IO Float) -> IO Float)
-> (Ptr Capsule -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \Ptr Capsule
p2 ->
  Vec2 -> (Ptr Vec2 -> IO Float) -> IO Float
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Vec2
a3 ((Ptr Vec2 -> IO Float) -> IO Float)
-> (Ptr Vec2 -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
p3 ->
  QueryFilter -> (Ptr QueryFilter -> IO Float) -> IO Float
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with QueryFilter
a4 ((Ptr QueryFilter -> IO Float) -> IO Float)
-> (Ptr QueryFilter -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \Ptr QueryFilter
p4 ->
  WorldId
-> Ptr Vec2
-> Ptr Capsule
-> Ptr Vec2
-> Ptr QueryFilter
-> IO Float
c_b2World_CastMover WorldId
a0 Ptr Vec2
p1 Ptr Capsule
p2 Ptr Vec2
p3 Ptr QueryFilter
p4

{- | Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for
kinematic character movement. The mover capsule and the resulting planes are relative to the origin.

Binds @b2World_CollideMover@.
-}
collideMover
  :: WorldId
  -> Pos
  -- ^ @origin@
  -> Capsule
  -- ^ @mover@
  -> QueryFilter
  -> FunPtr PlaneResultFcn
  -> Ptr ()
  -- ^ @context@
  -> IO ()
collideMover :: WorldId
-> Vec2
-> Capsule
-> QueryFilter
-> FunPtr PlaneResultFcn
-> Ptr ()
-> IO ()
collideMover WorldId
a0 Vec2
a1 Capsule
a2 QueryFilter
a3 FunPtr PlaneResultFcn
a4 Ptr ()
a5 =
  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 ->
  Capsule -> (Ptr Capsule -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Capsule
a2 ((Ptr Capsule -> IO ()) -> IO ())
-> (Ptr Capsule -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Capsule
p2 ->
  QueryFilter -> (Ptr QueryFilter -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with QueryFilter
a3 ((Ptr QueryFilter -> IO ()) -> IO ())
-> (Ptr QueryFilter -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr QueryFilter
p3 ->
  WorldId
-> Ptr Vec2
-> Ptr Capsule
-> Ptr QueryFilter
-> FunPtr PlaneResultFcn
-> Ptr ()
-> IO ()
c_b2World_CollideMover WorldId
a0 Ptr Vec2
p1 Ptr Capsule
p2 Ptr QueryFilter
p3 FunPtr PlaneResultFcn
a4 Ptr ()
a5

{- | Enable\/disable sleep. If your application does not need sleeping, you can gain some performance
by disabling sleep completely at the world level.
See also b2WorldDef.

Binds @b2World_EnableSleeping@.
-}
enableSleeping
  :: WorldId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableSleeping :: WorldId -> Bool -> IO ()
enableSleeping WorldId
a0 Bool
a1 =
  WorldId -> CBool -> IO ()
c_b2World_EnableSleeping WorldId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Is body sleeping enabled?

Binds @b2World_IsSleepingEnabled@.
-}
isSleepingEnabled
  :: WorldId
  -> IO Bool
isSleepingEnabled :: WorldId -> IO Bool
isSleepingEnabled WorldId
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
<$> (WorldId -> IO CBool
c_b2World_IsSleepingEnabled WorldId
a0)

{- | Enable\/disable continuous collision between dynamic and static bodies. Generally you should keep continuous
collision enabled to prevent fast moving objects from going through static objects. The performance gain from
disabling continuous collision is minor.
See also b2WorldDef.

Binds @b2World_EnableContinuous@.
-}
enableContinuous
  :: WorldId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableContinuous :: WorldId -> Bool -> IO ()
enableContinuous WorldId
a0 Bool
a1 =
  WorldId -> CBool -> IO ()
c_b2World_EnableContinuous WorldId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Is continuous collision enabled?

Binds @b2World_IsContinuousEnabled@.
-}
isContinuousEnabled
  :: WorldId
  -> IO Bool
isContinuousEnabled :: WorldId -> IO Bool
isContinuousEnabled WorldId
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
<$> (WorldId -> IO CBool
c_b2World_IsContinuousEnabled WorldId
a0)

{- | Adjust the restitution threshold. It is recommended not to make this value very small
because it will prevent bodies from sleeping. Usually in meters per second.
See also b2WorldDef.

Binds @b2World_SetRestitutionThreshold@.
-}
setRestitutionThreshold
  :: WorldId
  -> Float
  -- ^ @value@
  -> IO ()
setRestitutionThreshold :: WorldId -> Float -> IO ()
setRestitutionThreshold WorldId
a0 Float
a1 =
  WorldId -> Float -> IO ()
c_b2World_SetRestitutionThreshold WorldId
a0 Float
a1

{- | Get the the restitution speed threshold. Usually in meters per second.

Binds @b2World_GetRestitutionThreshold@.
-}
getRestitutionThreshold
  :: WorldId
  -> IO Float
getRestitutionThreshold :: WorldId -> IO Float
getRestitutionThreshold WorldId
a0 =
  WorldId -> IO Float
c_b2World_GetRestitutionThreshold WorldId
a0

{- | Adjust the hit event threshold. This controls the collision speed needed to generate a b2ContactHitEvent.
Usually in meters per second.
See also b2WorldDef::hitEventThreshold.

Binds @b2World_SetHitEventThreshold@.
-}
setHitEventThreshold
  :: WorldId
  -> Float
  -- ^ @value@
  -> IO ()
setHitEventThreshold :: WorldId -> Float -> IO ()
setHitEventThreshold WorldId
a0 Float
a1 =
  WorldId -> Float -> IO ()
c_b2World_SetHitEventThreshold WorldId
a0 Float
a1

{- | Get the the hit event speed threshold. Usually in meters per second.

Binds @b2World_GetHitEventThreshold@.
-}
getHitEventThreshold
  :: WorldId
  -> IO Float
getHitEventThreshold :: WorldId -> IO Float
getHitEventThreshold WorldId
a0 =
  WorldId -> IO Float
c_b2World_GetHitEventThreshold WorldId
a0

{- | Register the custom filter callback. This is optional.

Binds @b2World_SetCustomFilterCallback@.
-}
setCustomFilterCallback
  :: WorldId
  -> FunPtr CustomFilterFcn
  -> Ptr ()
  -- ^ @context@
  -> IO ()
setCustomFilterCallback :: WorldId -> FunPtr CustomFilterFcn -> Ptr () -> IO ()
setCustomFilterCallback WorldId
a0 FunPtr CustomFilterFcn
a1 Ptr ()
a2 =
  WorldId -> FunPtr CustomFilterFcn -> Ptr () -> IO ()
c_b2World_SetCustomFilterCallback WorldId
a0 FunPtr CustomFilterFcn
a1 Ptr ()
a2

{- | Register the pre-solve callback. This is optional.

Binds @b2World_SetPreSolveCallback@.
-}
setPreSolveCallback
  :: WorldId
  -> FunPtr PreSolveFcn
  -> Ptr ()
  -- ^ @context@
  -> IO ()
setPreSolveCallback :: WorldId -> FunPtr PreSolveFcn -> Ptr () -> IO ()
setPreSolveCallback WorldId
a0 FunPtr PreSolveFcn
a1 Ptr ()
a2 =
  WorldId -> FunPtr PreSolveFcn -> Ptr () -> IO ()
c_b2World_SetPreSolveCallback WorldId
a0 FunPtr PreSolveFcn
a1 Ptr ()
a2

{- | Set the gravity vector for the entire world. Box2D has no concept of an up direction and this
is left as a decision for the application. Usually in m\/s^2.
See also b2WorldDef.

Binds @b2World_SetGravity@.
-}
setGravity
  :: WorldId
  -> Vec2
  -- ^ @gravity@
  -> IO ()
setGravity :: WorldId -> Vec2 -> IO ()
setGravity WorldId
a0 Vec2
a1 =
  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 ->
  WorldId -> Ptr Vec2 -> IO ()
c_b2World_SetGravity WorldId
a0 Ptr Vec2
p1

{- | Get the gravity vector

Binds @b2World_GetGravity@.
-}
getGravity
  :: WorldId
  -> IO Vec2
getGravity :: WorldId -> IO Vec2
getGravity WorldId
a0 =
  (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 -> WorldId -> Ptr Vec2 -> IO ()
c_b2World_GetGravity WorldId
a0 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

-- | Like 'getGravity', but the result is written into a caller-supplied buffer.
getGravityInto
  :: WorldId
  -> Ptr Vec2
  -- ^ Result buffer.
  -> IO ()
getGravityInto :: WorldId -> Ptr Vec2 -> IO ()
getGravityInto WorldId
a0 Ptr Vec2
out =
  WorldId -> Ptr Vec2 -> IO ()
c_b2World_GetGravity WorldId
a0 Ptr Vec2
out

{- | Apply a radial explosion

Binds @b2World_Explode@.
-}
explode
  :: WorldId
  -- ^ @worldId@: The world id
  -> ExplosionDef
  -- ^ @explosionDef@: The explosion definition
  -> IO ()
explode :: WorldId -> ExplosionDef -> IO ()
explode WorldId
a0 ExplosionDef
a1 =
  ExplosionDef -> (Ptr ExplosionDef -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with ExplosionDef
a1 ((Ptr ExplosionDef -> IO ()) -> IO ())
-> (Ptr ExplosionDef -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr ExplosionDef
p1 ->
  WorldId -> Ptr ExplosionDef -> IO ()
c_b2World_Explode WorldId
a0 Ptr ExplosionDef
p1

{- | Adjust contact tuning parameters
Note: Advanced feature

Binds @b2World_SetContactTuning@.
-}
setContactTuning
  :: WorldId
  -- ^ @worldId@: The world id
  -> Float
  -- ^ @hertz@: The contact stiffness (cycles per second)
  -> Float
  -- ^ @dampingRatio@: The contact bounciness with 1 being critical damping (non-dimensional)
  -> Float
  -- ^ @pushSpeed@: The maximum contact constraint push out speed (meters per second)
  -> IO ()
setContactTuning :: WorldId -> Float -> Float -> Float -> IO ()
setContactTuning WorldId
a0 Float
a1 Float
a2 Float
a3 =
  WorldId -> Float -> Float -> Float -> IO ()
c_b2World_SetContactTuning WorldId
a0 Float
a1 Float
a2 Float
a3

{- | Set the contact point recycling distance. Setting this to zero disables contact point recycling.
Usually in meters.

Binds @b2World_SetContactRecycleDistance@.
-}
setContactRecycleDistance
  :: WorldId
  -> Float
  -- ^ @recycleDistance@
  -> IO ()
setContactRecycleDistance :: WorldId -> Float -> IO ()
setContactRecycleDistance WorldId
a0 Float
a1 =
  WorldId -> Float -> IO ()
c_b2World_SetContactRecycleDistance WorldId
a0 Float
a1

{- | Get the contact point recycling distance. Usually in meters.

Binds @b2World_GetContactRecycleDistance@.
-}
getContactRecycleDistance
  :: WorldId
  -> IO Float
getContactRecycleDistance :: WorldId -> IO Float
getContactRecycleDistance WorldId
a0 =
  WorldId -> IO Float
c_b2World_GetContactRecycleDistance WorldId
a0

{- | Set the maximum linear speed. Usually in m\/s.

Binds @b2World_SetMaximumLinearSpeed@.
-}
setMaximumLinearSpeed
  :: WorldId
  -> Float
  -- ^ @maximumLinearSpeed@
  -> IO ()
setMaximumLinearSpeed :: WorldId -> Float -> IO ()
setMaximumLinearSpeed WorldId
a0 Float
a1 =
  WorldId -> Float -> IO ()
c_b2World_SetMaximumLinearSpeed WorldId
a0 Float
a1

{- | Get the maximum linear speed. Usually in m\/s.

Binds @b2World_GetMaximumLinearSpeed@.
-}
getMaximumLinearSpeed
  :: WorldId
  -> IO Float
getMaximumLinearSpeed :: WorldId -> IO Float
getMaximumLinearSpeed WorldId
a0 =
  WorldId -> IO Float
c_b2World_GetMaximumLinearSpeed WorldId
a0

{- | Enable\/disable constraint warm starting. Advanced feature for testing. Disabling
warm starting greatly reduces stability and provides no performance gain.

Binds @b2World_EnableWarmStarting@.
-}
enableWarmStarting
  :: WorldId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableWarmStarting :: WorldId -> Bool -> IO ()
enableWarmStarting WorldId
a0 Bool
a1 =
  WorldId -> CBool -> IO ()
c_b2World_EnableWarmStarting WorldId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Is constraint warm starting enabled?

Binds @b2World_IsWarmStartingEnabled@.
-}
isWarmStartingEnabled
  :: WorldId
  -> IO Bool
isWarmStartingEnabled :: WorldId -> IO Bool
isWarmStartingEnabled WorldId
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
<$> (WorldId -> IO CBool
c_b2World_IsWarmStartingEnabled WorldId
a0)

{- | Get the number of awake bodies.

Binds @b2World_GetAwakeBodyCount@.
-}
getAwakeBodyCount
  :: WorldId
  -> IO Int
getAwakeBodyCount :: WorldId -> IO Int
getAwakeBodyCount WorldId
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
<$> (WorldId -> IO CInt
c_b2World_GetAwakeBodyCount WorldId
a0)

{- | Get the current world performance profile

Binds @b2World_GetProfile@.
-}
getProfile
  :: WorldId
  -> Ptr Profile
  -- ^ Result buffer.
  -> IO ()
getProfile :: WorldId -> Ptr Profile -> IO ()
getProfile WorldId
a0 Ptr Profile
out =
  WorldId -> Ptr Profile -> IO ()
c_b2World_GetProfile WorldId
a0 Ptr Profile
out

{- | Get world counters and sizes

Binds @b2World_GetCounters@.
-}
getCounters
  :: WorldId
  -> Ptr Counters
  -- ^ Result buffer.
  -> IO ()
getCounters :: WorldId -> Ptr Counters -> IO ()
getCounters WorldId
a0 Ptr Counters
out =
  WorldId -> Ptr Counters -> IO ()
c_b2World_GetCounters WorldId
a0 Ptr Counters
out

{- | Get max capacity. This can be used with b2WorldDef to avoid run-time allocations and copies

Binds @b2World_GetMaxCapacity@.
-}
getMaxCapacity
  :: WorldId
  -> IO Capacity
getMaxCapacity :: WorldId -> IO Capacity
getMaxCapacity WorldId
a0 =
  (Ptr Capacity -> IO Capacity) -> IO Capacity
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Capacity -> IO Capacity) -> IO Capacity)
-> (Ptr Capacity -> IO Capacity) -> IO Capacity
forall a b. (a -> b) -> a -> b
$ \Ptr Capacity
pOut -> WorldId -> Ptr Capacity -> IO ()
c_b2World_GetMaxCapacity WorldId
a0 Ptr Capacity
pOut IO () -> IO Capacity -> IO Capacity
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Capacity -> IO Capacity
forall a. Storable a => Ptr a -> IO a
peek Ptr Capacity
pOut

-- | Like 'getMaxCapacity', but the result is written into a caller-supplied buffer.
getMaxCapacityInto
  :: WorldId
  -> Ptr Capacity
  -- ^ Result buffer.
  -> IO ()
getMaxCapacityInto :: WorldId -> Ptr Capacity -> IO ()
getMaxCapacityInto WorldId
a0 Ptr Capacity
out =
  WorldId -> Ptr Capacity -> IO ()
c_b2World_GetMaxCapacity WorldId
a0 Ptr Capacity
out

{- | Set the user data pointer.

Binds @b2World_SetUserData@.
-}
setUserData
  :: WorldId
  -> Ptr ()
  -- ^ @userData@
  -> IO ()
setUserData :: WorldId -> Ptr () -> IO ()
setUserData WorldId
a0 Ptr ()
a1 =
  WorldId -> Ptr () -> IO ()
c_b2World_SetUserData WorldId
a0 Ptr ()
a1

{- | Get the user data pointer.

Binds @b2World_GetUserData@.
-}
getUserData
  :: WorldId
  -> IO (Ptr ())
getUserData :: WorldId -> IO (Ptr ())
getUserData WorldId
a0 =
  WorldId -> IO (Ptr ())
c_b2World_GetUserData WorldId
a0

{- | Set the friction callback. Passing NULL resets to default.

Binds @b2World_SetFrictionCallback@.
-}
setFrictionCallback
  :: WorldId
  -> FunPtr FrictionCallback
  -> IO ()
setFrictionCallback :: WorldId -> FunPtr FrictionCallback -> IO ()
setFrictionCallback WorldId
a0 FunPtr FrictionCallback
a1 =
  WorldId -> FunPtr FrictionCallback -> IO ()
c_b2World_SetFrictionCallback WorldId
a0 FunPtr FrictionCallback
a1

{- | Set the restitution callback. Passing NULL resets to default.

Binds @b2World_SetRestitutionCallback@.
-}
setRestitutionCallback
  :: WorldId
  -> FunPtr RestitutionCallback
  -> IO ()
setRestitutionCallback :: WorldId -> FunPtr RestitutionCallback -> IO ()
setRestitutionCallback WorldId
a0 FunPtr RestitutionCallback
a1 =
  WorldId -> FunPtr RestitutionCallback -> IO ()
c_b2World_SetRestitutionCallback WorldId
a0 FunPtr RestitutionCallback
a1

{- | Set the worker count. Must be between in the range \[1, B2_MAX_WORKERS\]

Binds @b2World_SetWorkerCount@.
-}
setWorkerCount
  :: WorldId
  -> Int
  -- ^ @count@
  -> IO ()
setWorkerCount :: WorldId -> Int -> IO ()
setWorkerCount WorldId
a0 Int
a1 =
  WorldId -> CInt -> IO ()
c_b2World_SetWorkerCount WorldId
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1)

{- | Get the worker count.

Binds @b2World_GetWorkerCount@.
-}
getWorkerCount
  :: WorldId
  -> IO Int
getWorkerCount :: WorldId -> IO Int
getWorkerCount WorldId
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
<$> (WorldId -> IO CInt
c_b2World_GetWorkerCount WorldId
a0)

{- | Dump memory stats to box2d_memory.txt

Binds @b2World_DumpMemoryStats@.
-}
dumpMemoryStats
  :: WorldId
  -> IO ()
dumpMemoryStats :: WorldId -> IO ()
dumpMemoryStats WorldId
a0 =
  WorldId -> IO ()
c_b2World_DumpMemoryStats WorldId
a0

{- | This is for internal testing

Binds @b2World_RebuildStaticTree@.
-}
rebuildStaticTree
  :: WorldId
  -> IO ()
rebuildStaticTree :: WorldId -> IO ()
rebuildStaticTree WorldId
a0 =
  WorldId -> IO ()
c_b2World_RebuildStaticTree WorldId
a0

{- | This is for internal testing

Binds @b2World_EnableSpeculative@.
-}
enableSpeculative
  :: WorldId
  -> Bool
  -- ^ @flag@
  -> IO ()
enableSpeculative :: WorldId -> Bool -> IO ()
enableSpeculative WorldId
a0 Bool
a1 =
  WorldId -> CBool -> IO ()
c_b2World_EnableSpeculative WorldId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Begin recording the world into \@p recording. Serializes a snapshot of the current world as the
seed, then logs every mutating call. Call at a step boundary, before or after creating bodies.
Start before the first step to capture the whole session. No effect if already recording or if
the world is locked.

Binds @b2World_StartRecording@.
-}
startRecording
  :: WorldId
  -- ^ @worldId@: The world to record
  -> Ptr Recording
  -- ^ @recording@: A recording buffer from b2CreateRecording
  -> IO ()
startRecording :: WorldId -> Ptr Recording -> IO ()
startRecording WorldId
a0 Ptr Recording
a1 =
  WorldId -> Ptr Recording -> IO ()
c_b2World_StartRecording WorldId
a0 Ptr Recording
a1

{- | Stop recording. The recording buffer keeps its bytes. Save and destroy it yourself.

Binds @b2World_StopRecording@.
-}
stopRecording
  :: WorldId
  -- ^ @worldId@: The world being recorded
  -> IO ()
stopRecording :: WorldId -> IO ()
stopRecording WorldId
a0 =
  WorldId -> IO ()
c_b2World_StopRecording WorldId
a0

{- | Write a snapshot of the world\'s simulation state into a caller-owned buffer.
Call once with image == NULL to get the required size, then again with a buffer
of at least that size. Must be called at a step boundary.

Returns: The number of bytes the snapshot needs. If it exceeds capacity nothing is written. Returns 0 if the world is mid-step.

Binds @b2World_Snapshot@.
-}
snapshot
  :: WorldId
  -- ^ @worldId@: The world to snapshot
  -> Ptr Word8
  -- ^ @image@: Destination buffer, or NULL to query the size
  -> Int
  -- ^ @capacity@: Size of image in bytes, ignored when querying
  -> IO Int
snapshot :: WorldId -> Ptr Word8 -> Int -> IO Int
snapshot WorldId
a0 Ptr Word8
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
<$> (WorldId -> Ptr Word8 -> CInt -> IO CInt
c_b2World_Snapshot WorldId
a0 Ptr Word8
a1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2))

{- | Restore a world\'s simulation state from a snapshot image, in place. The world keeps
its slot and generation, so this b2WorldId and any ids held from this same world stay
valid for objects that existed at the snapshot instant. Host wiring is preserved.
Restore into the same world the snapshot came from to keep held ids valid. Must be
called at a step boundary.

Returns: true on success. On a rejected image (bad magic, version, or layout) the world is left unchanged. A corrupt payload detected after the rebuild begins returns false and leaves the world unusable, so the caller must destroy it.

Binds @b2World_Restore@.
-}
restore
  :: WorldId
  -- ^ @worldId@: The world to restore into
  -> Ptr Word8
  -- ^ @image@: A snapshot image produced by b2World_Snapshot
  -> Int
  -- ^ @size@: Size of image in bytes
  -> IO Bool
restore :: WorldId -> Ptr Word8 -> Int -> IO Bool
restore WorldId
a0 Ptr Word8
a1 Int
a2 =
  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
<$> (WorldId -> Ptr Word8 -> CInt -> IO CBool
c_b2World_Restore WorldId
a0 Ptr Word8
a1 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2))

{- | Create a new world from a snapshot image. Use this to load a saved world when there is
no existing world to restore into. The new world gets a fresh slot and id, so ids held
from the origin world will not match it. Host wiring is reset to defaults.

Returns: The new world id, or b2_nullWorldId on failure.

Binds @b2CreateWorldFromSnapshot@.
-}
createFromSnapshot
  :: Ptr Word8
  -- ^ @image@: A snapshot image produced by b2World_Snapshot
  -> Int
  -- ^ @size@: Size of image in bytes
  -> Int
  -- ^ @workerCount@: Worker count for the new world. 0 uses the serial single-worker fallback.
  -> IO WorldId
createFromSnapshot :: Ptr Word8 -> Int -> Int -> IO WorldId
createFromSnapshot Ptr Word8
a0 Int
a1 Int
a2 =
  Ptr Word8 -> CInt -> CInt -> IO WorldId
c_b2CreateWorldFromSnapshot Ptr Word8
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1) (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2)