Box2D
Safe HaskellNone
LanguageGHC2021

Box2D.DynamicTree

Synopsis

Documentation

create Source #

Arguments

:: Int
proxyCapacity
-> Ptr DynamicTree

Result buffer.

-> IO () 

Constructing the tree initializes the node pool.

Binds b2DynamicTree_Create.

destroy :: Ptr DynamicTree -> IO () Source #

Destroy the tree, freeing the node pool.

Binds b2DynamicTree_Destroy.

createProxy Source #

Arguments

:: Ptr DynamicTree 
-> AABB 
-> Word64
categoryBits
-> Word64
userData
-> IO Int 

Create a proxy. Provide an AABB and a userData value.

Binds b2DynamicTree_CreateProxy.

destroyProxy Source #

Arguments

:: Ptr DynamicTree 
-> Int
proxyId
-> IO () 

Destroy a proxy. This asserts if the id is invalid.

Binds b2DynamicTree_DestroyProxy.

moveProxy Source #

Arguments

:: Ptr DynamicTree 
-> Int
proxyId
-> AABB 
-> IO () 

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

Binds b2DynamicTree_MoveProxy.

enlargeProxy Source #

Arguments

:: Ptr DynamicTree 
-> Int
proxyId
-> AABB 
-> IO () 

Enlarge a proxy and enlarge ancestors as necessary.

Binds b2DynamicTree_EnlargeProxy.

setCategoryBits Source #

Arguments

:: Ptr DynamicTree 
-> Int
proxyId
-> Word64
categoryBits
-> IO () 

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

Binds b2DynamicTree_SetCategoryBits.

getCategoryBits Source #

Arguments

:: Ptr DynamicTree 
-> Int
proxyId
-> IO Word64 

Get the category bits on a proxy.

Binds b2DynamicTree_GetCategoryBits.

query Source #

Arguments

:: Ptr DynamicTree 
-> AABB 
-> Word64
maskBits
-> FunPtr TreeQueryCallbackFcn 
-> Ptr ()
context
-> IO TreeStats 

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.

queryAll Source #

Arguments

:: Ptr DynamicTree 
-> AABB 
-> FunPtr TreeQueryCallbackFcn 
-> Ptr ()
context
-> IO TreeStats 

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.

rayCast Source #

Arguments

:: 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 

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.

boxCast Source #

Arguments

:: 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 

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.

boxCastInto Source #

Arguments

:: 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 () 

Like boxCast, but the result is written into a caller-supplied buffer.

getHeight :: Ptr DynamicTree -> IO Int Source #

Get the height of the binary tree.

Binds b2DynamicTree_GetHeight.

getAreaRatio :: Ptr DynamicTree -> IO Float Source #

Get the ratio of the sum of the node areas to the root area.

Binds b2DynamicTree_GetAreaRatio.

getRootBounds :: Ptr DynamicTree -> IO AABB Source #

Get the bounding box that contains the entire tree

Binds b2DynamicTree_GetRootBounds.

getRootBoundsInto Source #

Arguments

:: Ptr DynamicTree 
-> Ptr AABB

Result buffer.

-> IO () 

Like getRootBounds, but the result is written into a caller-supplied buffer.

getProxyCount :: Ptr DynamicTree -> IO Int Source #

Get the number of proxies created

Binds b2DynamicTree_GetProxyCount.

rebuild Source #

Arguments

:: Ptr DynamicTree 
-> Bool
fullBuild
-> IO Int 

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

Binds b2DynamicTree_Rebuild.

getByteCount :: Ptr DynamicTree -> IO Int Source #

Get the number of bytes used by this tree

Binds b2DynamicTree_GetByteCount.

getUserData Source #

Arguments

:: Ptr DynamicTree 
-> Int
proxyId
-> IO Word64 

Get proxy user data

Binds b2DynamicTree_GetUserData.

getAABB Source #

Arguments

:: Ptr DynamicTree 
-> Int
proxyId
-> IO AABB 

Get the AABB of a proxy

Binds b2DynamicTree_GetAABB.

getAABBInto Source #

Arguments

:: Ptr DynamicTree 
-> Int
proxyId
-> Ptr AABB

Result buffer.

-> IO () 

Like getAABB, but the result is written into a caller-supplied buffer.

validate :: Ptr DynamicTree -> IO () Source #

Validate this tree. For testing.

Binds b2DynamicTree_Validate.

validateNoEnlarged :: Ptr DynamicTree -> IO () Source #

Validate this tree has no enlarged AABBs. For testing.

Binds b2DynamicTree_ValidateNoEnlarged.