Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Bevy 0.13 #315

Merged
merged 30 commits into from
Feb 20, 2024
Merged

Update to Bevy 0.13 #315

merged 30 commits into from
Feb 20, 2024

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Jan 27, 2024

Objective

Closes #314 and #317.

This PR will be merged once Bevy 0.13 is released. Feel free to use this bevy-main branch in the meantime if you want to use the main branch of Bevy with bevy_xpbd.

Solution

Update to the latest Bevy version.

For the 0.13 migration, I will be trying to implement various changes, mostly surrounding the new geometric primitives and ray structs. I will probably do these in PRs that I merge into this one, and it will all be merged into main once 0.13 is actually released.


Migration Guide

Debug rendering

The PhysicsDebugConfig resource and PhysicsDebugRenderer system parameter have been removed in favor of the new PhysicsGizmos gizmo configuration group.

Before:

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            PhysicsPlugins::default(),
            PhysicsDebugPlugin::default(),
        ))
        // Configure physics debug rendering
        .insert_resource(PhysicsDebugConfig {
            aabb_color: Some(Color::WHITE),
            ..default()
        })
        .run();
}

After:

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            PhysicsPlugins::default(),
            PhysicsDebugPlugin::default(),
        ))
        // Configure physics debug rendering
        .insert_gizmo_group(
            PhysicsGizmos {
                aabb_color: Some(Color::WHITE),
                ..default()
            },
            GizmoConfig::default(),
        )
        .run();
}

This also allows you to configure e.g. line width for just physics gizmos by configuring their GizmoConfig.

Renamed Collider constructors (#326)

  • Replace Collider::ball with Collider::circle in 2D and Collider::sphere in 3D
  • Replace Collider::cuboid with Collider::rectangle in 2D

Ray and shape casting (#329)

For spatial queries, replace Vec2/Vec3 directions with Direction2d/Direction3d.

// Before
let caster = RayCaster::new(Vec3::ZERO, Vec3::X);

// After
let caster = RayCaster::new(Vec3::ZERO, Direction3d::X);

This applies to RayCaster, ShapeCaster, SpatialQuery methods like cast_ray, and many other methods that use directions.

@ManevilleF ManevilleF mentioned this pull request Feb 18, 2024
4 tasks
# Objective

Support creating colliders from the new geometric primitives in Bevy 0.13.

## Solution

Add an `IntoCollider` trait and implement it for primitives. For now, tori and conical frusta are not supported, as they aren't as trivial to implement.

Some new collider shapes are also supported: ellipses and regular polygons. These are implemented using custom shapes, as Parry doesn't have them built-in.

`Collider::ball` is now also `Collider::circle` in 2D and `Collider::sphere` in 3D. `Collider::cuboid` is `Collider::rectangle` in 2D. This makes the naming consistent with Bevy. 

---

## Migration Guide

- Replace `Collider::ball` with `Collider::circle` in 2D and `Collider::sphere` in 3D
- Replace `Collider::cuboid` with `Collider::rectangle` in 2D
@Jondolf Jondolf linked an issue Feb 18, 2024 that may be closed by this pull request
…:from_ray` (#329)

# Objective

Bevy 0.13 added the `Direction2d` and `Direction3d` types along with `Ray2d` and `Ray3d` types. The new direction types are a great fit for ray directions, as they guarantee that the direction is normalized. This avoids the potential footgun where unnormalized directions are actually treated like velocity, which affects the time of impact.

Ray and shape casting APIs should use the direction types. It should also be possible to make a `RayCaster` from a ray conveniently.

## Solution

Add `Ray` and `Dir` type aliases to support 2D and 3D, and use `Dir` for directions for `RayCaster`, `ShapeCaster`, and `SpatialQuery` methods. I also added a `RayCaster::from_ray` constructor.

---

## Migration Guide

For spatial queries, replace `Vec2`/`Vec3` directions with `Direction2d`/`Direction3d`.

```rust
// Before
let caster = RayCaster::new(Vec3::ZERO, Vec3::X);

// After
let caster = RayCaster::new(Vec3::ZERO, Direction3d::X);
```
@Jondolf Jondolf marked this pull request as ready for review February 20, 2024 11:58
@Jondolf Jondolf merged commit dc98b65 into main Feb 20, 2024
4 checks passed
@Jondolf Jondolf deleted the bevy-main branch February 20, 2024 12:48
ManevilleF added a commit to ManevilleF/bevy_silk that referenced this pull request Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add ellipse collider. Migrate WorldQuery from Bevy
1 participant