This Week in Bevy

What happened this week in the Bevy Engine ecosystem

Links

BundleEffects, Fallible Observers, and Planetary meshes

2025-02-17

This week Bevy has upgraded to wgpu 24 and enabled unchecked shaders for added performance.

The next generation scene/ui system is also making headway with improved spawn apis and Bundle effects.

In the showcases this week we see a number of landscape and planetary terrain lod systems, with and without voxels.

Bevy's Next Generation Scene/UI System

Progress towards bsn continues with #17521: Improved Spawn APIs and Bundle Effects. Previously, it was common to spawn hierarchies of entities using the with_children or with_child apis.

commands
    .spawn(Foo)
    .with_children(|p| {
        p.spawn(Bar).with_children(|p| {
            p.spawn(Baz);
        });
        p.spawn(Bar).with_children(|p| {
            p.spawn(Baz);
        });
    });

A new BundleEffect trait has been added which in addition to other types (such as Spawn and SpawnRelated) results in the following next-generation macro-based hierarchy spawning experience.

world.spawn((
    Foo,
    children![
        (
            Bar,
            children![Baz],
        ),
        (
            Bar,
            children![Baz],
        ),
    ]
))

The order of events is

  1. The Bundle is inserted on the entity
  2. Relevant Hooks are run for the insert
  3. Relevant Observers are run
  4. The BundleEffect is run

Notably, this extends to any arbitrary Relationship, not just Children. All together this new functionality enables spawning hierarchies, lists, and relationships with or without macro syntax.

world.spawn((
    Foo,
    related!(Children[
        (
            Bar,
            related!(Children[Baz]),
        ),
        (
            Bar,
            related!(Children[Baz]),
        ),
    ])
))

and hierarchies can now be returned from functions.

fn button(text: &str, color: Color) -> impl Bundle {
    (
        Node {
            width: Val::Px(300.),
            height: Val::Px(100.),
            ..default()
        },
        BackgroundColor(color),
        children![
            Text::new(text),
        ]
    )
}

fn ui() -> impl Bundle {
    (
        Node {
            width: Val::Percent(100.0),
            height: Val::Percent(100.0),
            ..default(),
        },
        children![
            button("hello", BLUE),
            button("world", RED),
        ]
    )
}

fn system(mut commands: Commands) {
    commands.spawn(ui());
}

Fallible Observers

Building on top of fallible systems, Observers also receive the ability to fail in #17731. This means Observer functions can now take advantage of the ? operator.

fn fallible_observer(
    trigger: Trigger<Pointer<Move>>,
    mut world: DeferredWorld,
    mut step: Local<f32>,
) -> Result {
    let mut transform = world
        .get_mut::<Transform>(trigger.target)
        .ok_or("No transform found.")?;

    *step = if transform.translation.x > 3. {
        -0.1
    } else if transform.translation.x < -3. || *step == 0. {
        0.1
    } else {
        *step
    };

    transform.translation.x += *step;

    Ok(())
}

Fallible Systems

#17753 introduces configurable error handling for fallible systems at the global, Schedule, and individual system levels.

app.set_system_error_handler(bevy::ecs::result::warn);

MeshTag

Because of mesh preprocessing, @builtin(instance_index) is not stable and can't be used top reference external data. #17648 introduces a user supplied mesh index that can be used for referencing external data when drawing instanced meshes. The shader/automatic_instancing.rs example has been updated to show its usage.

Trait Tags

test tags

As of #17758 (which will affect Bevy 0.16's docs when it is released), Bevy's docs will have stylized tags for types that implement notable traits, such as Component, Resource, and more.

For example, the new MeshTag now has a Component tag, making it easier to identify as a Component.

MeshTag

New Examples


Alice's Merge Train is a maintainer-level view into active PRs, both those that are merging and those that need work.

Showcase

Bevy work from the #showcase channel in Discord and around the internet. Use hashtag #bevyengine.

landscape from heightmapslandscape from heightmapslandscape mesh

Landscape Meshes

showcase

Landscapes that can be created from heightmaps, now with support for fast dynamic LODs based on quadtrees.

particles

Particles

showcase

An asteroids style ship flying around breaking down other ship-like entities and asteroids into particles.

membooster v2

Membooster v2

showcase

Version 2 of Membooster, an iOS memory game. It now has a simple card guessing game, and is working on re-integrating bevy-vello since they've updated it to bevy 0.15.

planet surface polygonsworld polygons

Earth-sized Planet

showcase

An earth-sized planet subdivided down to sub-meter polygons. Meshes subdivide themselves as the player gets closer, and each mesh knows its latitude/longitude as well as barycentric coordinates relative to the 20 top-level icosahedral faces, which it will use to assign itself UVs and heights. The demo makes use of big_space

noumenal ray tracing

Noumenal’s main shader

showcase

Noumenal’s main shader, now with hybrid ray tracing. The shader computes everything from primitive surface data stored in storage buffers and screen coordinates.

voxel planetsvoxel planet landscapevoxel planet landscape wireframes

Full-size voxel planet project

showcase

Updates to this full-size voxel planet project include placing the planets on different voxel grids which allows to move the planets without changing the voxels.

verlet integrationverlet integration ropes

Verlet integration web slinging

showcase

Verlet Integration is a numerical method used to integrate Newton's equations of motion. This demo uses it to create a web slinging effect.

If you want to learn more about Verlet in game applications: Math for Game Programmers: Building a Better Jump covers some.

mesh dungeon generation

Procedural dungeon mesh generation

showcase

Mesh generation for a procedural dungeon. There are multiple floors which will be connected by a staircase.

flappy bird

Flappy

showcase

Flappy is a Bevy 0.15 Flappy Bird implementation that is deployed on the web to play and open source for educational purposes.

Crates

New releases to crates.io and substantial updates to existing projects

bevy_picking_bvh_backend

crate_release

bevy_picking_bvh_backend is an optimization to mesh picking using a BVH tree (Bounding Volume Hierarchy).

haalka

haalka 0.3.0

crate_release

haalka is an ergonomic reactivity library powered by the incredible FRP signals of futures-signals. It is a port of the web UI libraries MoonZoon and Dominator and offers the same signal semantics as a thin layer on top of bevy_ui. While haalka is primarily targeted at UI and provides high level UI abstractions as such, its core abstraction can be used to manage signals-powered reactivity for any entity, not just bevy_ui nodes.

bevy_webserver

crate_release

bevy_webserver is a web server integration that allows you to easily append a webserver to Bevy. It supports creating standalone webapps or appending a webserver to an existing bevy app/game.

bevy_easy_database

crate_release

bevy_easy_database is a persistent storage solution for that automatically serializes and persists your components to disk using fjall as the underlying database.

It supports automatic persistence, hot-reloading of component data, and selective persistence using marker components.

bevy_tailwind v0.2.3

crate_release

bevy_tailwind brings tailwind's classes to Bevy, generating Nodes from a tw macro.

tw!("p-1", {
    "pl-2": true,
    "px-3 pl-4": true,
    "p-5": true
});
No devlogs this week
No Educational this week
Pull Requests Merged This Week
Contributing

Want to contribute to Bevy?

Here you can find two types of potential contribution: Pull Requests that might need review and Issues that might need to be worked on.

How do I contribute?

Pull Requests Opened this week

Issues Opened this week