pub struct GpuBroadphase {
pub sweep_axis: usize,
pub margin: f32,
pub stats: CollisionKernelStats,
}Expand description
GPU-accelerated broadphase using Sort-and-Sweep (SAP).
Sorts AABB projections along a chosen axis (default X), sweeps for overlapping intervals, then validates the remaining axes and records broadphase pairs.
Fields§
§sweep_axis: usizeAxis along which to sort/sweep: 0=X, 1=Y, 2=Z.
margin: f32Inflation margin applied to each AABB before testing.
stats: CollisionKernelStatsStats from the most recent dispatch.
Implementations§
Source§impl GpuBroadphase
impl GpuBroadphase
Sourcepub fn new(sweep_axis: usize, margin: f32) -> Self
pub fn new(sweep_axis: usize, margin: f32) -> Self
Create a new GpuBroadphase with the given sweep axis and margin.
Sourcepub fn choose_best_axis(aabbs: &[AabbGpu]) -> usize
pub fn choose_best_axis(aabbs: &[AabbGpu]) -> usize
Choose the axis with the widest spread for better SAP performance.
Returns the axis index (0, 1, or 2).
Sourcepub fn dispatch(&mut self, aabbs: &[AabbGpu]) -> Vec<CollisionPair>
pub fn dispatch(&mut self, aabbs: &[AabbGpu]) -> Vec<CollisionPair>
Run the SAP broadphase and return overlapping pairs.
Complexity: O(n log n + k) where k is the number of pairs found.
Trait Implementations§
Source§impl Debug for GpuBroadphase
impl Debug for GpuBroadphase
Source§impl Default for GpuBroadphase
impl Default for GpuBroadphase
Source§fn default() -> GpuBroadphase
fn default() -> GpuBroadphase
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for GpuBroadphase
impl RefUnwindSafe for GpuBroadphase
impl Send for GpuBroadphase
impl Sync for GpuBroadphase
impl Unpin for GpuBroadphase
impl UnsafeUnpin for GpuBroadphase
impl UnwindSafe for GpuBroadphase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more