Struct box2d_rs::b2_broad_phase::B2broadPhase
source · pub struct B2broadPhase<UserDataType> { /* private fields */ }
Expand description
The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent overlap.
Implementations§
source§impl<UserDataType: Default + Clone> B2broadPhase<UserDataType>
impl<UserDataType: Default + Clone> B2broadPhase<UserDataType>
pub fn new() -> Self
sourcepub fn create_proxy(&mut self, aabb: B2AABB, user_data: &UserDataType) -> i32
pub fn create_proxy(&mut self, aabb: B2AABB, user_data: &UserDataType) -> i32
create a proxy with an initial AABB. Pairs are not reported until UpdatePairs is called.
sourcepub fn destroy_proxy(&mut self, proxy_id: i32)
pub fn destroy_proxy(&mut self, proxy_id: i32)
destroy a proxy. It is up to the client to remove any pairs.
sourcepub fn move_proxy(&mut self, proxy_id: i32, aabb: B2AABB, displacement: B2vec2)
pub fn move_proxy(&mut self, proxy_id: i32, aabb: B2AABB, displacement: B2vec2)
Call move_proxy as many times as you like, then when you are done call UpdatePairs to finalized the proxy pairs (for your time step).
sourcepub fn touch_proxy(&mut self, proxy_id: i32)
pub fn touch_proxy(&mut self, proxy_id: i32)
Call to trigger a re-processing of it’s pairs on the next call to UpdatePairs.
sourcepub fn get_fat_aabb(&self, proxy_id: i32) -> B2AABB
pub fn get_fat_aabb(&self, proxy_id: i32) -> B2AABB
Get the fat AABB for a proxy.
sourcepub fn get_user_data(&self, proxy_id: i32) -> Option<UserDataType>
pub fn get_user_data(&self, proxy_id: i32) -> Option<UserDataType>
Get user data from a proxy. Returns None if the id is invalid.
sourcepub fn test_overlap(&self, proxy_id_a: i32, proxy_id_b: i32) -> bool
pub fn test_overlap(&self, proxy_id_a: i32, proxy_id_b: i32) -> bool
Test overlap of fat AABBs.
sourcepub fn get_proxy_count(&self) -> i32
pub fn get_proxy_count(&self) -> i32
Get the number of proxies.
sourcepub fn update_pairs<CallbackType: AddPairTrait<UserDataType>>(
&mut self,
callback: &mut CallbackType
)
pub fn update_pairs<CallbackType: AddPairTrait<UserDataType>>( &mut self, callback: &mut CallbackType )
update the pairs. This results in pair callbacks. This can only add pairs.
sourcepub fn query<F: QueryCallback>(&self, callback: F, aabb: B2AABB)
pub fn query<F: QueryCallback>(&self, callback: F, aabb: B2AABB)
query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.
sourcepub fn ray_cast<T: RayCastCallback>(&self, callback: T, input: &B2rayCastInput)
pub fn ray_cast<T: RayCastCallback>(&self, callback: T, input: &B2rayCastInput)
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.
input
- the ray-cast input data. The ray extends from p1 to p1 + max_fraction * (p2 - p1).callback
- a callback class that is called for each proxy that is hit by the ray.
sourcepub fn get_tree_height(&self) -> i32
pub fn get_tree_height(&self) -> i32
Get the height of the embedded tree.
sourcepub fn get_tree_balance(&self) -> i32
pub fn get_tree_balance(&self) -> i32
Get the balance of the embedded tree.
sourcepub fn get_tree_quality(&self) -> f32
pub fn get_tree_quality(&self) -> f32
Get the quality metric of the embedded tree.
sourcepub fn shift_origin(&mut self, new_origin: B2vec2)
pub fn shift_origin(&mut self, new_origin: B2vec2)
Shift the world origin. Useful for large worlds. The shift formula is: position -= new_origin
new_origin
- the new origin with respect to the old origin