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

module Box2D.DynamicTree
  ( create
  , destroy
  , createProxy
  , destroyProxy
  , moveProxy
  , enlargeProxy
  , setCategoryBits
  , getCategoryBits
  , query
  , queryAll
  , rayCast
  , boxCast
  , boxCastInto
  , getHeight
  , getAreaRatio
  , getRootBounds
  , getRootBoundsInto
  , getProxyCount
  , rebuild
  , getByteCount
  , getUserData
  , getAABB
  , getAABBInto
  , validate
  , validateNoEnlarged
  )

  where

import Foreign
import Foreign.C.Types (CInt(..), CBool(..))
import Box2D.MathTypes (AABB)
import Box2D.Tags (BoxCastInput, DynamicTree, TreeBoxCastCallbackFcn, TreeQueryCallbackFcn, TreeRayCastCallbackFcn)
import Box2D.Types (RayCastInput, TreeStats)

foreign import ccall unsafe "hsg_b2DynamicTree_Create"
  c_b2DynamicTree_Create :: CInt -> Ptr DynamicTree -> IO ()

foreign import ccall unsafe "b2DynamicTree_Destroy"
  c_b2DynamicTree_Destroy :: Ptr DynamicTree -> IO ()

foreign import ccall unsafe "hsg_b2DynamicTree_CreateProxy"
  c_b2DynamicTree_CreateProxy :: Ptr DynamicTree -> Ptr AABB -> Word64 -> Word64 -> IO CInt

foreign import ccall unsafe "b2DynamicTree_DestroyProxy"
  c_b2DynamicTree_DestroyProxy :: Ptr DynamicTree -> CInt -> IO ()

foreign import ccall unsafe "hsg_b2DynamicTree_MoveProxy"
  c_b2DynamicTree_MoveProxy :: Ptr DynamicTree -> CInt -> Ptr AABB -> IO ()

foreign import ccall unsafe "hsg_b2DynamicTree_EnlargeProxy"
  c_b2DynamicTree_EnlargeProxy :: Ptr DynamicTree -> CInt -> Ptr AABB -> IO ()

foreign import ccall unsafe "b2DynamicTree_SetCategoryBits"
  c_b2DynamicTree_SetCategoryBits :: Ptr DynamicTree -> CInt -> Word64 -> IO ()

foreign import ccall unsafe "b2DynamicTree_GetCategoryBits"
  c_b2DynamicTree_GetCategoryBits :: Ptr DynamicTree -> CInt -> IO Word64

foreign import ccall safe "hsg_b2DynamicTree_Query"
  c_b2DynamicTree_Query :: Ptr DynamicTree -> Ptr AABB -> Word64 -> FunPtr TreeQueryCallbackFcn -> Ptr () -> Ptr TreeStats -> IO ()

foreign import ccall safe "hsg_b2DynamicTree_QueryAll"
  c_b2DynamicTree_QueryAll :: Ptr DynamicTree -> Ptr AABB -> FunPtr TreeQueryCallbackFcn -> Ptr () -> Ptr TreeStats -> IO ()

foreign import ccall safe "hsg_b2DynamicTree_RayCast"
  c_b2DynamicTree_RayCast :: Ptr DynamicTree -> Ptr RayCastInput -> Word64 -> FunPtr TreeRayCastCallbackFcn -> Ptr () -> Ptr TreeStats -> IO ()

foreign import ccall safe "hsg_b2DynamicTree_BoxCast"
  c_b2DynamicTree_BoxCast :: Ptr DynamicTree -> Ptr BoxCastInput -> Word64 -> FunPtr TreeBoxCastCallbackFcn -> Ptr () -> Ptr TreeStats -> IO ()

foreign import ccall unsafe "b2DynamicTree_GetHeight"
  c_b2DynamicTree_GetHeight :: Ptr DynamicTree -> IO CInt

foreign import ccall unsafe "b2DynamicTree_GetAreaRatio"
  c_b2DynamicTree_GetAreaRatio :: Ptr DynamicTree -> IO Float

foreign import ccall unsafe "hsg_b2DynamicTree_GetRootBounds"
  c_b2DynamicTree_GetRootBounds :: Ptr DynamicTree -> Ptr AABB -> IO ()

foreign import ccall unsafe "b2DynamicTree_GetProxyCount"
  c_b2DynamicTree_GetProxyCount :: Ptr DynamicTree -> IO CInt

foreign import ccall unsafe "b2DynamicTree_Rebuild"
  c_b2DynamicTree_Rebuild :: Ptr DynamicTree -> CBool -> IO CInt

foreign import ccall unsafe "b2DynamicTree_GetByteCount"
  c_b2DynamicTree_GetByteCount :: Ptr DynamicTree -> IO CInt

foreign import ccall unsafe "b2DynamicTree_GetUserData"
  c_b2DynamicTree_GetUserData :: Ptr DynamicTree -> CInt -> IO Word64

foreign import ccall unsafe "hsg_b2DynamicTree_GetAABB"
  c_b2DynamicTree_GetAABB :: Ptr DynamicTree -> CInt -> Ptr AABB -> IO ()

foreign import ccall unsafe "b2DynamicTree_Validate"
  c_b2DynamicTree_Validate :: Ptr DynamicTree -> IO ()

foreign import ccall unsafe "b2DynamicTree_ValidateNoEnlarged"
  c_b2DynamicTree_ValidateNoEnlarged :: Ptr DynamicTree -> IO ()

{- | Constructing the tree initializes the node pool.

Binds @b2DynamicTree_Create@.
-}
create
  :: Int
  -- ^ @proxyCapacity@
  -> Ptr DynamicTree
  -- ^ Result buffer.
  -> IO ()
create :: Int -> Ptr DynamicTree -> IO ()
create Int
a0 Ptr DynamicTree
out =
  CInt -> Ptr DynamicTree -> IO ()
c_b2DynamicTree_Create (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a0) Ptr DynamicTree
out

{- | Destroy the tree, freeing the node pool.

Binds @b2DynamicTree_Destroy@.
-}
destroy
  :: Ptr DynamicTree
  -> IO ()
destroy :: Ptr DynamicTree -> IO ()
destroy Ptr DynamicTree
a0 =
  Ptr DynamicTree -> IO ()
c_b2DynamicTree_Destroy Ptr DynamicTree
a0

{- | Create a proxy. Provide an AABB and a userData value.

Binds @b2DynamicTree_CreateProxy@.
-}
createProxy
  :: Ptr DynamicTree
  -> AABB
  -> Word64
  -- ^ @categoryBits@
  -> Word64
  -- ^ @userData@
  -> IO Int
createProxy :: Ptr DynamicTree -> AABB -> Word64 -> Word64 -> IO Int
createProxy Ptr DynamicTree
a0 AABB
a1 Word64
a2 Word64
a3 =
  AABB -> (Ptr AABB -> IO Int) -> IO Int
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with AABB
a1 ((Ptr AABB -> IO Int) -> IO Int) -> (Ptr AABB -> IO Int) -> IO Int
forall a b. (a -> b) -> a -> b
$ \Ptr AABB
p1 ->
  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
<$> (Ptr DynamicTree -> Ptr AABB -> Word64 -> Word64 -> IO CInt
c_b2DynamicTree_CreateProxy Ptr DynamicTree
a0 Ptr AABB
p1 Word64
a2 Word64
a3)

{- | Destroy a proxy. This asserts if the id is invalid.

Binds @b2DynamicTree_DestroyProxy@.
-}
destroyProxy
  :: Ptr DynamicTree
  -> Int
  -- ^ @proxyId@
  -> IO ()
destroyProxy :: Ptr DynamicTree -> Int -> IO ()
destroyProxy Ptr DynamicTree
a0 Int
a1 =
  Ptr DynamicTree -> CInt -> IO ()
c_b2DynamicTree_DestroyProxy Ptr DynamicTree
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1)

{- | Move a proxy to a new AABB by removing and reinserting into the tree.

Binds @b2DynamicTree_MoveProxy@.
-}
moveProxy
  :: Ptr DynamicTree
  -> Int
  -- ^ @proxyId@
  -> AABB
  -> IO ()
moveProxy :: Ptr DynamicTree -> Int -> AABB -> IO ()
moveProxy Ptr DynamicTree
a0 Int
a1 AABB
a2 =
  AABB -> (Ptr AABB -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with AABB
a2 ((Ptr AABB -> IO ()) -> IO ()) -> (Ptr AABB -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr AABB
p2 ->
  Ptr DynamicTree -> CInt -> Ptr AABB -> IO ()
c_b2DynamicTree_MoveProxy Ptr DynamicTree
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1) Ptr AABB
p2

{- | Enlarge a proxy and enlarge ancestors as necessary.

Binds @b2DynamicTree_EnlargeProxy@.
-}
enlargeProxy
  :: Ptr DynamicTree
  -> Int
  -- ^ @proxyId@
  -> AABB
  -> IO ()
enlargeProxy :: Ptr DynamicTree -> Int -> AABB -> IO ()
enlargeProxy Ptr DynamicTree
a0 Int
a1 AABB
a2 =
  AABB -> (Ptr AABB -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with AABB
a2 ((Ptr AABB -> IO ()) -> IO ()) -> (Ptr AABB -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr AABB
p2 ->
  Ptr DynamicTree -> CInt -> Ptr AABB -> IO ()
c_b2DynamicTree_EnlargeProxy Ptr DynamicTree
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1) Ptr AABB
p2

{- | Modify the category bits on a proxy. This is an expensive operation.

Binds @b2DynamicTree_SetCategoryBits@.
-}
setCategoryBits
  :: Ptr DynamicTree
  -> Int
  -- ^ @proxyId@
  -> Word64
  -- ^ @categoryBits@
  -> IO ()
setCategoryBits :: Ptr DynamicTree -> Int -> Word64 -> IO ()
setCategoryBits Ptr DynamicTree
a0 Int
a1 Word64
a2 =
  Ptr DynamicTree -> CInt -> Word64 -> IO ()
c_b2DynamicTree_SetCategoryBits Ptr DynamicTree
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1) Word64
a2

{- | Get the category bits on a proxy.

Binds @b2DynamicTree_GetCategoryBits@.
-}
getCategoryBits
  :: Ptr DynamicTree
  -> Int
  -- ^ @proxyId@
  -> IO Word64
getCategoryBits :: Ptr DynamicTree -> Int -> IO Word64
getCategoryBits Ptr DynamicTree
a0 Int
a1 =
  Ptr DynamicTree -> CInt -> IO Word64
c_b2DynamicTree_GetCategoryBits Ptr DynamicTree
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1)

{- | Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.

Returns: performance data

Binds @b2DynamicTree_Query@.
-}
query
  :: Ptr DynamicTree
  -> AABB
  -> Word64
  -- ^ @maskBits@
  -> FunPtr TreeQueryCallbackFcn
  -> Ptr ()
  -- ^ @context@
  -> IO TreeStats
query :: Ptr DynamicTree
-> AABB
-> Word64
-> FunPtr TreeQueryCallbackFcn
-> Ptr ()
-> IO TreeStats
query Ptr DynamicTree
a0 AABB
a1 Word64
a2 FunPtr TreeQueryCallbackFcn
a3 Ptr ()
a4 =
  AABB -> (Ptr AABB -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with AABB
a1 ((Ptr AABB -> IO TreeStats) -> IO TreeStats)
-> (Ptr AABB -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr AABB
p1 ->
  (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 -> Ptr DynamicTree
-> Ptr AABB
-> Word64
-> FunPtr TreeQueryCallbackFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2DynamicTree_Query Ptr DynamicTree
a0 Ptr AABB
p1 Word64
a2 FunPtr TreeQueryCallbackFcn
a3 Ptr ()
a4 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

{- | Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.
No filtering is performed.

Returns: performance data

Binds @b2DynamicTree_QueryAll@.
-}
queryAll
  :: Ptr DynamicTree
  -> AABB
  -> FunPtr TreeQueryCallbackFcn
  -> Ptr ()
  -- ^ @context@
  -> IO TreeStats
queryAll :: Ptr DynamicTree
-> AABB -> FunPtr TreeQueryCallbackFcn -> Ptr () -> IO TreeStats
queryAll Ptr DynamicTree
a0 AABB
a1 FunPtr TreeQueryCallbackFcn
a2 Ptr ()
a3 =
  AABB -> (Ptr AABB -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with AABB
a1 ((Ptr AABB -> IO TreeStats) -> IO TreeStats)
-> (Ptr AABB -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr AABB
p1 ->
  (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 -> Ptr DynamicTree
-> Ptr AABB
-> FunPtr TreeQueryCallbackFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2DynamicTree_QueryAll Ptr DynamicTree
a0 Ptr AABB
p1 FunPtr TreeQueryCallbackFcn
a2 Ptr ()
a3 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

{- | Ray cast against the proxies in the tree. This relies on the callback
to perform a exact ray cast in the case were the proxy contains a shape.
The callback also performs the any collision filtering. This has performance
roughly equal to k * log(n), where k is the number of collisions and n is the
number of proxies in the tree.
Bit-wise filtering using mask bits can greatly improve performance in some scenarios.
However, this filtering may be approximate, so the user should still apply filtering to results.

Returns: performance data

Binds @b2DynamicTree_RayCast@.
-}
rayCast
  :: Ptr DynamicTree
  -- ^ @tree@: the dynamic tree to ray cast
  -> RayCastInput
  -- ^ @input@: the ray cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1)
  -> Word64
  -- ^ @maskBits@: mask bit hint: \`bool accept = (maskBits & node-\>categoryBits) != 0;\`
  -> FunPtr TreeRayCastCallbackFcn
  -- ^ @callback@: a callback class that is called for each proxy that is hit by the ray
  -> Ptr ()
  -- ^ @context@: user context that is passed to the callback
  -> IO TreeStats
rayCast :: Ptr DynamicTree
-> RayCastInput
-> Word64
-> FunPtr TreeRayCastCallbackFcn
-> Ptr ()
-> IO TreeStats
rayCast Ptr DynamicTree
a0 RayCastInput
a1 Word64
a2 FunPtr TreeRayCastCallbackFcn
a3 Ptr ()
a4 =
  RayCastInput -> (Ptr RayCastInput -> IO TreeStats) -> IO TreeStats
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with RayCastInput
a1 ((Ptr RayCastInput -> IO TreeStats) -> IO TreeStats)
-> (Ptr RayCastInput -> IO TreeStats) -> IO TreeStats
forall a b. (a -> b) -> a -> b
$ \Ptr RayCastInput
p1 ->
  (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 -> Ptr DynamicTree
-> Ptr RayCastInput
-> Word64
-> FunPtr TreeRayCastCallbackFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2DynamicTree_RayCast Ptr DynamicTree
a0 Ptr RayCastInput
p1 Word64
a2 FunPtr TreeRayCastCallbackFcn
a3 Ptr ()
a4 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 swept AABB through the tree. This has performance roughly equal to k * log(n),
where k is the number of collisions and n is the number of proxies in the tree.

Returns: performance data

Binds @b2DynamicTree_BoxCast@.
-}
boxCast
  :: Ptr DynamicTree
  -- ^ @tree@: the dynamic tree to cast through
  -> Ptr BoxCastInput
  -- ^ @input@: the AABB cast input. The box sweeps from its origin to origin + maxFraction * translation.
  -> Word64
  -- ^ @maskBits@: filter bits: \`bool accept = (maskBits & node-\>categoryBits) != 0;\`
  -> FunPtr TreeBoxCastCallbackFcn
  -- ^ @callback@: a callback that is called for each proxy the swept box may hit
  -> Ptr ()
  -- ^ @context@: user context that is passed to the callback
  -> IO TreeStats
boxCast :: Ptr DynamicTree
-> Ptr BoxCastInput
-> Word64
-> FunPtr TreeBoxCastCallbackFcn
-> Ptr ()
-> IO TreeStats
boxCast Ptr DynamicTree
a0 Ptr BoxCastInput
a1 Word64
a2 FunPtr TreeBoxCastCallbackFcn
a3 Ptr ()
a4 =
  (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 -> Ptr DynamicTree
-> Ptr BoxCastInput
-> Word64
-> FunPtr TreeBoxCastCallbackFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2DynamicTree_BoxCast Ptr DynamicTree
a0 Ptr BoxCastInput
a1 Word64
a2 FunPtr TreeBoxCastCallbackFcn
a3 Ptr ()
a4 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

-- | Like 'boxCast', but the result is written into a caller-supplied buffer.
boxCastInto
  :: Ptr DynamicTree
  -- ^ @tree@: the dynamic tree to cast through
  -> Ptr BoxCastInput
  -- ^ @input@: the AABB cast input. The box sweeps from its origin to origin + maxFraction * translation.
  -> Word64
  -- ^ @maskBits@: filter bits: \`bool accept = (maskBits & node-\>categoryBits) != 0;\`
  -> FunPtr TreeBoxCastCallbackFcn
  -- ^ @callback@: a callback that is called for each proxy the swept box may hit
  -> Ptr ()
  -- ^ @context@: user context that is passed to the callback
  -> Ptr TreeStats
  -- ^ Result buffer.
  -> IO ()
boxCastInto :: Ptr DynamicTree
-> Ptr BoxCastInput
-> Word64
-> FunPtr TreeBoxCastCallbackFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
boxCastInto Ptr DynamicTree
a0 Ptr BoxCastInput
a1 Word64
a2 FunPtr TreeBoxCastCallbackFcn
a3 Ptr ()
a4 Ptr TreeStats
out =
  Ptr DynamicTree
-> Ptr BoxCastInput
-> Word64
-> FunPtr TreeBoxCastCallbackFcn
-> Ptr ()
-> Ptr TreeStats
-> IO ()
c_b2DynamicTree_BoxCast Ptr DynamicTree
a0 Ptr BoxCastInput
a1 Word64
a2 FunPtr TreeBoxCastCallbackFcn
a3 Ptr ()
a4 Ptr TreeStats
out

{- | Get the height of the binary tree.

Binds @b2DynamicTree_GetHeight@.
-}
getHeight
  :: Ptr DynamicTree
  -> IO Int
getHeight :: Ptr DynamicTree -> IO Int
getHeight Ptr DynamicTree
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
<$> (Ptr DynamicTree -> IO CInt
c_b2DynamicTree_GetHeight Ptr DynamicTree
a0)

{- | Get the ratio of the sum of the node areas to the root area.

Binds @b2DynamicTree_GetAreaRatio@.
-}
getAreaRatio
  :: Ptr DynamicTree
  -> IO Float
getAreaRatio :: Ptr DynamicTree -> IO Float
getAreaRatio Ptr DynamicTree
a0 =
  Ptr DynamicTree -> IO Float
c_b2DynamicTree_GetAreaRatio Ptr DynamicTree
a0

{- | Get the bounding box that contains the entire tree

Binds @b2DynamicTree_GetRootBounds@.
-}
getRootBounds
  :: Ptr DynamicTree
  -> IO AABB
getRootBounds :: Ptr DynamicTree -> IO AABB
getRootBounds Ptr DynamicTree
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 -> Ptr DynamicTree -> Ptr AABB -> IO ()
c_b2DynamicTree_GetRootBounds Ptr DynamicTree
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 'getRootBounds', but the result is written into a caller-supplied buffer.
getRootBoundsInto
  :: Ptr DynamicTree
  -> Ptr AABB
  -- ^ Result buffer.
  -> IO ()
getRootBoundsInto :: Ptr DynamicTree -> Ptr AABB -> IO ()
getRootBoundsInto Ptr DynamicTree
a0 Ptr AABB
out =
  Ptr DynamicTree -> Ptr AABB -> IO ()
c_b2DynamicTree_GetRootBounds Ptr DynamicTree
a0 Ptr AABB
out

{- | Get the number of proxies created

Binds @b2DynamicTree_GetProxyCount@.
-}
getProxyCount
  :: Ptr DynamicTree
  -> IO Int
getProxyCount :: Ptr DynamicTree -> IO Int
getProxyCount Ptr DynamicTree
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
<$> (Ptr DynamicTree -> IO CInt
c_b2DynamicTree_GetProxyCount Ptr DynamicTree
a0)

{- | Rebuild the tree while retaining subtrees that haven\'t changed. Returns the number of boxes sorted.

Binds @b2DynamicTree_Rebuild@.
-}
rebuild
  :: Ptr DynamicTree
  -> Bool
  -- ^ @fullBuild@
  -> IO Int
rebuild :: Ptr DynamicTree -> Bool -> IO Int
rebuild Ptr DynamicTree
a0 Bool
a1 =
  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
<$> (Ptr DynamicTree -> CBool -> IO CInt
c_b2DynamicTree_Rebuild Ptr DynamicTree
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1))

{- | Get the number of bytes used by this tree

Binds @b2DynamicTree_GetByteCount@.
-}
getByteCount
  :: Ptr DynamicTree
  -> IO Int
getByteCount :: Ptr DynamicTree -> IO Int
getByteCount Ptr DynamicTree
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
<$> (Ptr DynamicTree -> IO CInt
c_b2DynamicTree_GetByteCount Ptr DynamicTree
a0)

{- | Get proxy user data

Binds @b2DynamicTree_GetUserData@.
-}
getUserData
  :: Ptr DynamicTree
  -> Int
  -- ^ @proxyId@
  -> IO Word64
getUserData :: Ptr DynamicTree -> Int -> IO Word64
getUserData Ptr DynamicTree
a0 Int
a1 =
  Ptr DynamicTree -> CInt -> IO Word64
c_b2DynamicTree_GetUserData Ptr DynamicTree
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1)

{- | Get the AABB of a proxy

Binds @b2DynamicTree_GetAABB@.
-}
getAABB
  :: Ptr DynamicTree
  -> Int
  -- ^ @proxyId@
  -> IO AABB
getAABB :: Ptr DynamicTree -> Int -> IO AABB
getAABB Ptr DynamicTree
a0 Int
a1 =
  (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 -> Ptr DynamicTree -> CInt -> Ptr AABB -> IO ()
c_b2DynamicTree_GetAABB Ptr DynamicTree
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1) Ptr AABB
pOut IO () -> IO AABB -> IO AABB
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr AABB -> IO AABB
forall a. Storable a => Ptr a -> IO a
peek Ptr AABB
pOut

-- | Like 'getAABB', but the result is written into a caller-supplied buffer.
getAABBInto
  :: Ptr DynamicTree
  -> Int
  -- ^ @proxyId@
  -> Ptr AABB
  -- ^ Result buffer.
  -> IO ()
getAABBInto :: Ptr DynamicTree -> Int -> Ptr AABB -> IO ()
getAABBInto Ptr DynamicTree
a0 Int
a1 Ptr AABB
out =
  Ptr DynamicTree -> CInt -> Ptr AABB -> IO ()
c_b2DynamicTree_GetAABB Ptr DynamicTree
a0 (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1) Ptr AABB
out

{- | Validate this tree. For testing.

Binds @b2DynamicTree_Validate@.
-}
validate
  :: Ptr DynamicTree
  -> IO ()
validate :: Ptr DynamicTree -> IO ()
validate Ptr DynamicTree
a0 =
  Ptr DynamicTree -> IO ()
c_b2DynamicTree_Validate Ptr DynamicTree
a0

{- | Validate this tree has no enlarged AABBs. For testing.

Binds @b2DynamicTree_ValidateNoEnlarged@.
-}
validateNoEnlarged
  :: Ptr DynamicTree
  -> IO ()
validateNoEnlarged :: Ptr DynamicTree -> IO ()
validateNoEnlarged Ptr DynamicTree
a0 =
  Ptr DynamicTree -> IO ()
c_b2DynamicTree_ValidateNoEnlarged Ptr DynamicTree
a0