Skip to content

Update to Bevy 0.17#815

Merged
Jondolf merged 36 commits into
mainfrom
bevy-0.17
Sep 30, 2025
Merged

Update to Bevy 0.17#815
Jondolf merged 36 commits into
mainfrom
bevy-0.17

Conversation

@Jondolf

@Jondolf Jondolf commented Sep 15, 2025

Copy link
Copy Markdown
Member

Objective

Update Avian to Bevy 0.17!

Solution

  • Migrate to Bevy 0.17.0-rc
  • Rework collision events to work with the new event architecture
    • Combine CollisionStarted, CollisionEnded, OnCollisionStart, and OnCollisionEnd into CollisionStart and CollisionEnd events
    • All collision events are now both written as a Message and triggered as an Event
  • Rename system sets from FooSet to the new FooSystems convention
  • Remove manual type registrations
  • Migrate to using Parry's new Bvh instead of the old Qbvh

Migration Guide

Collision Events

The CollisionStarted, CollisionEnded, OnCollisionStart, and OnCollisionEnd events have been replaced by the CollisionStart and CollisionEnd events. They are both written as a Message and triggered as an Event, and store the collider and body entity of both colliders involved in the event.

A collision event observer before:

fn on_player_stepped_on_plate(event: Trigger<OnCollisionStart>, player_query: Query<&Player>) {
    let pressure_plate = event.target();
    let other_entity = event.collider;

    if player_query.contains(other_entity) {
        println!("Player {other_entity} stepped on pressure plate {pressure_plate}");
    }
}

and after:

fn on_player_stepped_on_plate(event: On<CollisionStart>, player_query: Query<&Player>) {
    let pressure_plate = event.collider1;
    let other_entity = event.collider2;

    if player_query.contains(other_entity) {
        println!("Player {other_entity} stepped on pressure plate {pressure_plate}");
    }
}

A collision event reader system before:

fn print_started_collisions(mut collision_reader: EventReader<CollisionStarted>) {
    for CollisionStarted(collider1, collider2) in collision_reader.read() {
        println!("{collider1} and {collider2} started colliding");
    }
}

and after:

fn print_started_collisions(mut collision_reader: MessageReader<CollisionStart>) {
    // Note: The event now also stores `body1` and `body2`
    for event in collision_reader.read() {
        println!("{} and {} started colliding", event.collider1, event.collider2);
    }
}

System Sets

System sets have been renamed to follow the new FooSystems naming convention.

  • PhysicsSetPhysicsSystems
  • PhysicsStepSetPhysicsStepSystems
  • SubstepSetSubstepSystems
  • SubstepSolverSetSubstepSolverSystems
  • SolverSetSolverSystems
  • IntegrationSetIntegrationSystems
  • BroadPhaseSetBroadPhaseSystems
  • NarrowPhaseSetNarrowPhaseSystems
  • SweptCcdSetSweptCcdSystems
  • PhysicsTransformSetPhysicsTransformSystems

ColliderConstructorHierarchy

Bevy 0.17 changed the way Name works for glTF mesh primitives (migration guide). Instead of MeshName.PrimitiveIndex, it is now in the form of MeshName.MaterialName. This also means that APIs such as ColliderConstructorHierarchy::with_constructor_for_name now use this format.

ColliderConstructorHierarchy::new(ColliderConstructor::ConvexDecompositionFromMesh)
    .with_density_for_name("armL_mesh.ferris_material", 3.0)
    .with_density_for_name("armR_mesh.ferris_material", 3.0)

@Jondolf Jondolf marked this pull request as draft September 15, 2025 18:08
Jondolf and others added 10 commits September 16, 2025 20:20
fix "temporaries freed while still in use" across a couple of function uses.

## Solution

I took the approach of keeping the clones of things like `DebugName` from the `.name` function, etc and instead stored the value so it could be referenced, since the usage relies on deref coercion to go from `DebugName` to `&str`.

The examples run after this fix
# Objective

Stop receiving a weird error `could not compile derive_more: at least one derive feature must be enabled`.

## Solution

Update `derive_more` to v2. This is aligned with the version used by Bevy in `0.17`.
@Jondolf Jondolf added the C-Dependencies A change to the crates that Avian depends on label Sep 28, 2025
@Jondolf Jondolf added this to the 0.4 milestone Sep 28, 2025
@Jondolf Jondolf marked this pull request as ready for review September 28, 2025 12:09
@Jondolf Jondolf added A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide labels Sep 30, 2025
@Jondolf Jondolf enabled auto-merge (squash) September 30, 2025 22:49
@Jondolf Jondolf merged commit 465b513 into main Sep 30, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality C-Dependencies A change to the crates that Avian depends on M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants