Skip to content

Commit

Permalink
Use IntersectsVolume for breakout example collisions (#11500)
Browse files Browse the repository at this point in the history
# Objective

Fixes #11479

## Solution

- Remove `collide_aabb.rs`
- Re-implement the example-specific collision code in the example,
taking advantage of the new `IntersectsVolume` trait.

## Changelog

- Removed `sprite::collide_aabb::collide` and
`sprite::collide_aabb::Collision`.

## Migration Guide

`sprite::collide_aabb::collide` and `sprite::collide_aabb::Collision`
were removed.

```rust
// Before
let collision = bevy::sprite::collide_aabb::collide(a_pos, a_size, b_pos, b_size);
if collision.is_some() {
    // ...
}

// After
let collision = Aabb2d::new(a_pos.truncate(), a_size / 2.)
    .intersects(&Aabb2d::new(b_pos.truncate(), b_size / 2.));
if collision {
    // ...
}
```

If you were making use `collide_aabb::Collision`, see the new
`collide_with_side` function in the [`breakout`
example](https://bevyengine.org/examples/Games/breakout/).

## Discussion

As discussed in the linked issue, maybe we want to wait on `bevy_sprite`
generally making use of `Aabb2b` so users don't need to construct it
manually. But since they **do** need to construct the bounding circle
for the ball manually, this doesn't seem like a big deal to me.

---------

Co-authored-by: IQuick 143 <IQuick143cz@gmail.com>
  • Loading branch information
rparrett and IQuick143 authored Jan 29, 2024
1 parent 16ce8c6 commit 1bc293f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 309 deletions.
297 changes: 0 additions & 297 deletions crates/bevy_sprite/src/collide_aabb.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/bevy_sprite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ mod texture_atlas;
mod texture_atlas_builder;
mod texture_slice;

pub mod collide_aabb;

pub mod prelude {
#[doc(hidden)]
pub use crate::{
Expand Down
Loading

0 comments on commit 1bc293f

Please sign in to comment.