pub struct DynamicTree { /* private fields */ }Expand description
The dynamic tree structure. (b2DynamicTree)
A dynamic AABB tree broad-phase. Leaf nodes are proxies with an AABB, used to hold a user collision object. Nodes are pooled and relocatable, so node indices are used rather than pointers.
Implementations§
Source§impl DynamicTree
impl DynamicTree
Sourcepub fn create_proxy(
&mut self,
aabb: Aabb,
category_bits: u64,
user_data: u64,
) -> i32
pub fn create_proxy( &mut self, aabb: Aabb, category_bits: u64, user_data: u64, ) -> i32
Create a proxy in the tree as a leaf node. Returns the node index. (b2DynamicTree_CreateProxy)
Sourcepub fn destroy_proxy(&mut self, proxy_id: i32)
pub fn destroy_proxy(&mut self, proxy_id: i32)
Destroy a proxy. This asserts if the id is invalid. (b2DynamicTree_DestroyProxy)
Sourcepub fn move_proxy(&mut self, proxy_id: i32, aabb: Aabb)
pub fn move_proxy(&mut self, proxy_id: i32, aabb: Aabb)
Move a proxy to a new AABB by removing and reinserting into the tree. (b2DynamicTree_MoveProxy)
Sourcepub fn enlarge_proxy(&mut self, proxy_id: i32, aabb: Aabb)
pub fn enlarge_proxy(&mut self, proxy_id: i32, aabb: Aabb)
Enlarge a proxy and enlarge ancestors as necessary. (b2DynamicTree_EnlargeProxy)
Sourcepub fn set_category_bits(&mut self, proxy_id: i32, category_bits: u64)
pub fn set_category_bits(&mut self, proxy_id: i32, category_bits: u64)
Modify the category bits on a proxy. This is an expensive operation. (b2DynamicTree_SetCategoryBits)
Source§impl DynamicTree
impl DynamicTree
Sourcepub fn query(
&self,
aabb: Aabb,
mask_bits: u64,
callback: impl FnMut(i32, u64) -> bool,
) -> TreeStats
pub fn query( &self, aabb: Aabb, mask_bits: u64, callback: impl FnMut(i32, u64) -> bool, ) -> TreeStats
Query an AABB for overlapping proxies. The callback is called for each proxy that overlaps the supplied AABB and passes the mask-bits filter; return false from the callback to stop. (b2DynamicTree_Query)
Sourcepub fn query_all(
&self,
aabb: Aabb,
callback: impl FnMut(i32, u64) -> bool,
) -> TreeStats
pub fn query_all( &self, aabb: Aabb, callback: impl FnMut(i32, u64) -> bool, ) -> TreeStats
Query an AABB for overlapping proxies with no filtering. (b2DynamicTree_QueryAll)
Sourcepub fn ray_cast(
&self,
input: &RayCastInput,
mask_bits: u64,
callback: impl FnMut(&RayCastInput, i32, u64) -> f32,
) -> TreeStats
pub fn ray_cast( &self, input: &RayCastInput, mask_bits: u64, callback: impl FnMut(&RayCastInput, i32, u64) -> f32, ) -> TreeStats
Ray cast against the proxies in the tree. The callback performs an exact ray cast when the proxy contains a shape, and returns the new ray fraction:
- return 0 to terminate the ray cast
- return a value less than the input max_fraction to clip the ray
- return the input max_fraction to continue without clipping
(b2DynamicTree_RayCast)
Sourcepub fn box_cast(
&self,
input: &BoxCastInput,
mask_bits: u64,
callback: impl FnMut(&BoxCastInput, i32, u64) -> f32,
) -> TreeStats
pub fn box_cast( &self, input: &BoxCastInput, mask_bits: u64, callback: impl FnMut(&BoxCastInput, i32, u64) -> f32, ) -> TreeStats
Cast a swept AABB through the tree. The callback returns the new cast
fraction, with the same semantics as DynamicTree::ray_cast.
(b2DynamicTree_BoxCast)
Source§impl DynamicTree
impl DynamicTree
Source§impl DynamicTree
impl DynamicTree
Sourcepub fn validate_no_enlarged(&self)
pub fn validate_no_enlarged(&self)
Validate this tree has no enlarged AABBs. For testing. (b2DynamicTree_ValidateNoEnlarged)
Source§impl DynamicTree
impl DynamicTree
Sourcepub fn new(proxy_capacity: i32) -> DynamicTree
pub fn new(proxy_capacity: i32) -> DynamicTree
Constructing the tree initializes the node pool. (b2DynamicTree_Create)
Sourcepub fn destroy(&mut self)
pub fn destroy(&mut self)
Destroy the tree, freeing the node pool. (b2DynamicTree_Destroy)
Rust would drop the storage automatically; this mirrors the C function (which leaves a zeroed struct) so ported call sites and tests read the same.
Sourcepub fn node_count(&self) -> i32
pub fn node_count(&self) -> i32
The number of allocated nodes.
Sourcepub fn proxy_count(&self) -> i32
pub fn proxy_count(&self) -> i32
Get the number of proxies created. (b2DynamicTree_GetProxyCount)
Sourcepub fn category_bits(&self, proxy_id: i32) -> u64
pub fn category_bits(&self, proxy_id: i32) -> u64
Get the category bits on a proxy. (b2DynamicTree_GetCategoryBits)
Sourcepub fn area_ratio(&self) -> f32
pub fn area_ratio(&self) -> f32
Get the ratio of the sum of the node areas to the root area. (b2DynamicTree_GetAreaRatio)
Sourcepub fn root_bounds(&self) -> Aabb
pub fn root_bounds(&self) -> Aabb
Get the bounding box that contains the entire tree. (b2DynamicTree_GetRootBounds)
Sourcepub fn byte_count(&self) -> i32
pub fn byte_count(&self) -> i32
Get the number of bytes used by this tree. (b2DynamicTree_GetByteCount)
Trait Implementations§
Source§impl Clone for DynamicTree
impl Clone for DynamicTree
Source§fn clone(&self) -> DynamicTree
fn clone(&self) -> DynamicTree
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more