Box3D
Safe HaskellNone
LanguageGHC2021

Box3D.DynamicTree

Synopsis

Documentation

create Source #

Arguments

:: Int
proxyCapacity
-> Ptr DynamicTree

Result buffer.

-> IO () 

Constructing the tree initializes the node pool.

Binds b3DynamicTree_Create.

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

Destroy the tree, freeing the node pool.

Binds b3DynamicTree_Destroy.

createProxy Source #

Arguments

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

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

Binds b3DynamicTree_CreateProxy.

destroyProxy Source #

Arguments

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

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

Binds b3DynamicTree_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 b3DynamicTree_MoveProxy.

enlargeProxy Source #

Arguments

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

Enlarge a proxy and enlarge ancestors as necessary.

Binds b3DynamicTree_EnlargeProxy.

setCategoryBits Source #

Arguments

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

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

Binds b3DynamicTree_SetCategoryBits.

getCategoryBits Source #

Arguments

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

Get the category bits on a proxy.

Binds b3DynamicTree_GetCategoryBits.

query Source #

Arguments

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

Query an AABB for overlapping proxies. The callback function is called for each proxy that overlaps the supplied AABB.

Returns: performance data

Binds b3DynamicTree_Query.

queryClosest Source #

Arguments

:: Ptr DynamicTree

tree: the dynamic tree to query

-> Vec3

point: the query point

-> Word64

maskBits: nodes are skipped if the bit-wise AND with the node category bits is zero

-> Bool

requireAllBits: nodes are skipped if the bit-wise AND with the node category bits does not equal the maskBits

-> FunPtr TreeQueryClosestCallbackFcn

callback: a user provided instance of b3TreeQueryClosestCallbackFcn

-> Ptr ()

context: a user context object that is provided to the callback

-> Ptr Float

minDistanceSqr: the initial and final minimum squared distance. Provide a small initial to restrict the search and improve performance. If the value is large this query has performance that scales linearly with the number of proxies and would be slower than a brute force search.

-> IO TreeStats 

Query an AABB for the closest object. The callback function is called for each proxy that might be closest to the supplied point.

Returns: performance data

Binds b3DynamicTree_QueryClosest.

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: bit mask test: `bool accept = (maskBits & node->categoryBits) != 0;`

-> Bool

requireAllBits: modifies bit mask test: `bool accept = (maskBits & node->categoryBits) == maskBits;`

-> FunPtr TreeRayCastCallbackFcn

callback: a callback function 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 an exact ray cast in the case where the proxy contains a shape. The callback also performs 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 b3DynamicTree_RayCast.

boxCast Source #

Arguments

:: Ptr DynamicTree 
-> Ptr BoxCastInput 
-> Word64
maskBits
-> Bool
requireAllBits
-> FunPtr TreeBoxCastCallbackFcn 
-> Ptr ()
context
-> IO TreeStats 

Sweep an AABB through the tree. The box is in the tree's world float frame and the callback re-differences each shape at full precision against the query origin. Used by the large world spatial queries so the tree traversal stays float while the narrow phase stays precise.

Binds b3DynamicTree_BoxCast.

boxCastInto Source #

Arguments

:: Ptr DynamicTree 
-> Ptr BoxCastInput 
-> Word64
maskBits
-> Bool
requireAllBits
-> FunPtr TreeBoxCastCallbackFcn 
-> Ptr ()
context
-> Ptr TreeStats

Result buffer.

-> IO () 

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

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

Validate this tree. For testing.

Binds b3DynamicTree_Validate.

getHeight :: Ptr DynamicTree -> IO Int Source #

Get the height of the binary tree.

Binds b3DynamicTree_GetHeight.

getAreaRatio :: Ptr DynamicTree -> IO Float Source #

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

Binds b3DynamicTree_GetAreaRatio.

getRootBounds :: Ptr DynamicTree -> IO AABB Source #

Get the bounding box that contains the entire tree

Binds b3DynamicTree_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 b3DynamicTree_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 b3DynamicTree_Rebuild.

getByteCount :: Ptr DynamicTree -> IO Int Source #

Get the number of bytes used by this tree

Binds b3DynamicTree_GetByteCount.

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

Validate this tree has no enlarged AABBs. For testing.

Binds b3DynamicTree_ValidateNoEnlarged.

save Source #

Arguments

:: Ptr DynamicTree 
-> CString
fileName
-> IO () 

Save this tree to a file for debugging

Binds b3DynamicTree_Save.

load Source #

Arguments

:: CString
fileName
-> Float
scale
-> Ptr DynamicTree

Result buffer.

-> IO () 

Load a file for debugging

Binds b3DynamicTree_Load.