Commit Graph

9271 Commits

Author SHA1 Message Date
Christian Hughes
7ae8b53923
Remove SystemSetNode (#20100)
# Objective

`SystemSetNode` doesn't really add much value beyond a couple helper
functions for getting the name as a string and checking if its a
`SystemTypeSet`. We can replace it entirely and use `InternedSystemSet`
directly by inlining these helper functions' usages without sacrificing
readability.

## Solution

Remove it and replace it with direct `InternedSystemSet` usage.

## Testing

Reusing current tests.
2025-07-13 17:25:46 +00:00
Talin
ace0114bdd
Changing the notification protocol for core_widgets. (#20086)
Notifications now include the source entity. This is useful for
callbacks that are responsible for more than one widget.

Part of #19236 

This is an incremental change only: I have not altered the fundamental
nature of callbacks, as this is still in discussion. The only change
here is to include the source entity id with the notification.

The existing examples don't leverage this new field, but that will
change when I work on the color sliders PR.

I have been careful not to use the word "events" in describing the
notification message structs because they are not capital-E `Events` at
this time. That may change depending on the outcome of discussions.

@alice-i-cecile
2025-07-13 17:25:11 +00:00
JMS55
e5aa94132c
Solari initial GI (#20020)
# Objective
- Add 1-bounce RT GI

## Solution

- Implement a very very basic version of ReSTIR GI
https://d1qx31qr3h6wln.cloudfront.net/publications/ReSTIR%20GI.pdf
- Pretty much a copy of the ReSTIR DI code, but adjusted for GI. 
- Didn't implement add more spatial samples, or do anything needed for
better quality.
- Didn't try to improve perf at all yet (it's actually faster than DI
though, unfortunately 😅)
- Didn't spend any time cleaning up the shared abstractions between
DI/GI

---

## Showcase
<img width="2564" height="1500" alt="image"
src="https://github.com/user-attachments/assets/1ff7be1c-7d7d-4e53-8aa6-bcec1553db3f"
/>
2025-07-13 17:23:38 +00:00
onbjerg
1525dff7ad
Add max_history_length to EntityCountDiagnosticsPlugin (#20085)
# Objective

I was building out a diagnostics panel in egui when I noticed that I
could specify the max history length for the
`FrameTimeDiagnosticsPlugin`, but not for the
`EntityCountDiagnosticsPlugin`. The objective was to harmonize the two,
making the diagnostic history length configurable for both.

## Solution

I added a `EntityCountDiagnosticsPlugin::new`, and a `Default` impl that
matches `FrameTimeDiagnosticsPlugin`.

This is a breaking change, given the plugin had no fields previously.

## Testing

I did not test this.
2025-07-12 23:00:38 +00:00
Guillaume Gomez
27fe2e88bd
Update sysinfo version to 0.36.0 (#20084)
Some bugfixes and new API additions.
2025-07-12 22:40:36 +00:00
Christian Hughes
f1eace62f0
Thoroughly document UninitializedId semantics (#20080)
# Objective

Clean up documentation around `UninitializedId`, which has slightly
confusing semantics.

## Solution

Added documentation comments on `UninitializedId`.

---------

Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
2025-07-12 03:56:23 +00:00
atlv
20dfae9a2d
Factor out up-choice in shadow cubemap sampling orthonormalize (#20052)
# Objective

- Another step towards unifying our orthonormal basis construction
#20050
- Preserve behavior but fix a bug. Unification will be a followup after
these two PRs and will need more thorough testing.

## Solution

- Make shadow cubemap sampling orthonormalize have the same function
signature as the other orthonormal basis functions in bevy

## Testing

- 3d_scene + lighting examples
2025-07-11 12:19:02 +00:00
atlv
b3032e06bd
Fix adapter forcing breaking wasm builds (#20054)
# Objective

- Appease @mockersf 

## Solution

- Gate out enumerate_adapters usage on wasm and warn if
`WGPU_FORCE_FALLBACK_ADAPTER` is somehow used.
2025-07-11 12:18:23 +00:00
atlv
cfb679a752
Add a release note for scene types refactor (#20051)
Its really barebones but I'm not sure what else to write.

---------

Co-authored-by: Robert Swain <robert.swain@gmail.com>
2025-07-11 07:34:06 +00:00
ickshonpe
df5dfcd298
OverrideClip interaction fix (#20064)
# Objective

Picking was changed in the UI transform PR to walk up the tree
recursively to check if an interaction was on a clipped node.
`OverrideClip` only affects a node's local clipping rect, so valid
interactions can be ignored if a node has clipped ancestors.

## Solution

Add a `Without<OverrideClip>` query filter to the picking systems'
`child_of_query`s.

## Testing

This modified `button` example can be used to test the change:
```rust
//! This example illustrates how to create a button that changes color and text based on its
//! interaction state.

use bevy::{color::palettes::basic::*, input_focus::InputFocus, prelude::*, winit::WinitSettings};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Only run the app when there is user input. This will significantly reduce CPU/GPU use.
        .insert_resource(WinitSettings::desktop_app())
        // `InputFocus` must be set for accessibility to recognize the button.
        .init_resource::<InputFocus>()
        .add_systems(Startup, setup)
        .add_systems(Update, button_system)
        .run();
}

const NORMAL_BUTTON: Color = Color::srgb(0.15, 0.15, 0.15);
const HOVERED_BUTTON: Color = Color::srgb(0.25, 0.25, 0.25);
const PRESSED_BUTTON: Color = Color::srgb(0.35, 0.75, 0.35);

fn button_system(
    mut input_focus: ResMut<InputFocus>,
    mut interaction_query: Query<
        (
            Entity,
            &Interaction,
            &mut BackgroundColor,
            &mut BorderColor,
            &mut Button,
            &Children,
        ),
        Changed<Interaction>,
    >,
    mut text_query: Query<&mut Text>,
) {
    for (entity, interaction, mut color, mut border_color, mut button, children) in
        &mut interaction_query
    {
        let mut text = text_query.get_mut(children[0]).unwrap();

        match *interaction {
            Interaction::Pressed => {
                input_focus.set(entity);
                **text = "Press".to_string();
                *color = PRESSED_BUTTON.into();
                *border_color = BorderColor::all(RED.into());

                // The accessibility system's only update the button's state when the `Button` component is marked as changed.
                button.set_changed();
            }
            Interaction::Hovered => {
                input_focus.set(entity);
                **text = "Hover".to_string();
                *color = HOVERED_BUTTON.into();
                *border_color = BorderColor::all(Color::WHITE);
                button.set_changed();
            }
            Interaction::None => {
                input_focus.clear();
                **text = "Button".to_string();
                *color = NORMAL_BUTTON.into();
                *border_color = BorderColor::all(Color::BLACK);
            }
        }
    }
}

fn setup(mut commands: Commands, assets: Res<AssetServer>) {
    // ui camera
    commands.spawn(Camera2d);
    commands.spawn(button(&assets));
}

fn button(asset_server: &AssetServer) -> impl Bundle + use<> {
    (
        Node {
            width: Val::Percent(100.0),
            height: Val::Percent(100.0),
            align_items: AlignItems::Center,
            justify_content: JustifyContent::Center,
            ..default()
        },
        children![(
            Node {
                width: Val::Px(0.),
                height: Val::Px(0.),
                overflow: Overflow::clip(),
                ..default()
            },
            children![(
                //OverrideClip,
                Button,
                Node {
                    position_type: PositionType::Absolute,
                    width: Val::Px(150.0),
                    height: Val::Px(65.0),
                    border: UiRect::all(Val::Px(5.0)),
                    // horizontally center child text
                    justify_content: JustifyContent::Center,
                    // vertically center child text
                    align_items: AlignItems::Center,
                    ..default()
                },
                BorderColor::all(Color::WHITE),
                BorderRadius::MAX,
                BackgroundColor(Color::BLACK),
                children![(
                    Text::new("Button"),
                    TextFont {
                        font: asset_server.load("fonts/FiraSans-Bold.ttf"),
                        font_size: 33.0,
                        ..default()
                    },
                    TextColor(Color::srgb(0.9, 0.9, 0.9)),
                    TextShadow::default(),
                )]
            )],
        )],
    )
}
```
On main the button ignores interactions, with this PR it should respond
correctly.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-07-11 05:02:36 +00:00
ickshonpe
63dd8b6652
ColorStop constructor functions (#20066)
# Objective

Add `px` and `percent` constructor functions for `ColorStop`.
2025-07-11 05:02:15 +00:00
JMS55
83305afa66
Fix SSAO specular occlusion roughness bug (#20067)
Noticed that we're converting perceptual_roughness to roughness for SSAO
specular occlusion up here, _but_ that happens _before_ we sample the
metallic_roughness texture map. So we're using the wrong roughness. I
assume this is a bug and was not intentional.

Suggest reviewing while hiding the whitespace diff.
2025-07-11 05:01:15 +00:00
Greeble
f8680135ed
Fix crash on meshes with morphs + skins + motion blur when not using storage buffers (#20076)
## Objective

Fixes #20058

## Solution

Fix the `dynamic_offsets` array being too small if a mesh has morphs and
skins and motion blur, and the renderer isn't using storage buffers
(i.e. WebGL2). The bug was introduced in #13572.

## Testing

- Minimal repro: https://github.com/M4tsuri/bevy_reproduce.
- Also examples `animated_mesh`, `morph_targets`,
`test_invalid_skinned_meshes`.
- As far as I can tell Bevy doesn't have any examples or tests that can
repro the problem combination.

Tested with WebGL and native, Win10/Chrome/Nvidia.
2025-07-11 05:00:42 +00:00
JMS55
0d6c591491
Adjust specular_multiscatter to not take LightingInput (#20068)
Small refactor for a future bevy_solari PR.

Suggest reviewing while hiding the whitespace diff.
2025-07-11 04:54:53 +00:00
T772
6792cebfd0
StandardMaterial docs: Make clear that lighting won't look correct if is_srgb is true (#20037)
# Objective

- Fix https://github.com/bevyengine/bevy/issues/12123

## Solution

- Add a code example found here:
https://github.com/bevyengine/bevy/blob/main/examples/3d/parallax_mapping.rs#L209
to https://docs.rs/bevy/latest/bevy/pbr/struct.StandardMaterial.html

## Testing

- This pull request if only changing docs. But I tested the formatting
via ```cargo doc --no-deps --open```.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com>
2025-07-10 18:41:37 +00:00
Tim
cb64a4aa8a
Refactor 3d_viewport_to_world example with let chains (#20071)
# Objective

Make use of let chains to reduce LoC where we previously used let else
to cut down on indentation. Best of both worlds.
2025-07-10 02:37:56 +00:00
andriyDev
c9c8964857
Add release notes and a migration guide for RenderStartup. (#20024)
# Objective

- Document #19887 changes.

## Solution

- Just some writing for Mwriting Monday!

---------

Co-authored-by: atlv <email@atlasdostal.com>
2025-07-09 23:40:42 +00:00
Giacomo Stevanato
6f6d8312f3
Split component.rs (#20063)
# Objective

- `component.rs` is becoming quite big, let's split it.

## Solution

- Split `component.rs` into the following:
- `component/mod.rs`: the new root of the `component` module: contains
the `Component` trait and a few other very generic items
  - `component/clone.rs`: contains component cloning related items
  - `component/tick.rs`: contains `Tick` and other tick related items
- future possibilities: move these into `change_detection`; however I
wanted to keep this PR without breaking changes
- `component/register.rs`: contains component registration (included
queued) related items
- `component/required.rs`: contains items and functions for properly
computing required components
- `component/info.rs`: contains items for storing component info and
metadata in the `World`
2025-07-09 20:07:11 +00:00
Talin
f2d25355c3
SliderPrecision component (#20032)
This PR adds a `SliderPrecision` component that lets you control the
rounding when dragging a slider.

Part of #19236
2025-07-09 20:06:58 +00:00
Carter Anderson
c65ef19b7c
Friendlier Entity Debug impl (#20045)
# Objective

The current Entity Debug impl prints the bit representation. This is an
"overshare". Debug is in many ways the primary interface into Entity, as
people derive Debug on their entity-containing types when they want to
inspect them. The bits take up too much space in the console and
obfuscate the useful information (entity index and generation).

## Solution

Use the Display implementation in Debug as well. Direct people
interested in bits to `Entity::to_bits` in the docs.
2025-07-09 19:15:37 +00:00
JMS55
1a3b26d433
Use PluginGroup for SolariPlugins (#20044) 2025-07-09 18:31:39 +00:00
Daniel Skates
d45ae74286
Add frame_time graph to fps_overlay v2 (#19277)
# Objective

- Rebase of https://github.com/bevyengine/bevy/pull/12561 , note that
this is blocked on "up-streaming
[iyes_perf_ui](https://crates.io/crates/iyes_perf_ui)" , but that work
seems to also be stalled

> Frame time is often more important to know than FPS but because of the
temporal nature of it, just seeing a number is not enough. Seeing a
graph that shows the history makes it easier to reason about
performance.

## Solution

> This PR adds a bar graph of the frame time history.
> 
> Each bar is scaled based on the frame time where a bigger frame time
will give a taller and wider bar.
> 
> The color also scales with that frame time where red is at or bellow
the minimum target fps and green is at or above the target maximum frame
rate. Anything between those 2 values will be interpolated between green
and red based on the frame time.
> 
> The algorithm is highly inspired by this article:
https://asawicki.info/news_1758_an_idea_for_visualization_of_frame_times

## Testing

- Ran `cargo run --example fps_overlay --features="bevy_dev_tools"`

---------

Co-authored-by: IceSentry <c.giguere42@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-07-09 16:59:21 +00:00
Brian Reavis
d40c5b54ae
Material, mesh, skin extraction optimization (#17976)
# Objective

The extraction systems for materials, meshes, and skins previously
iterated over `RemovedComponents<ViewVisibility>` in addition to more
specific variants like `RemovedComponents<MeshMaterial3d<M>>`. This
caused each system to loop through and check many irrelevant despawned
entities—sometimes multiple times. With many material types, this
overhead added up and became noticeable in frames with many despawns.

<img width="1091" alt="Screenshot 2025-02-21 at 10 28 01 AM"
src="https://github.com/user-attachments/assets/63fec1c9-232c-45f6-9150-daf8751ecf85"
/>

## Solution

This PR removes superfluous `RemovedComponents` iteration for
`ViewVisibility` and `GlobalTransform`, ensuring that we only iterate
over the most specific `RemovedComponents` relevant to the system (e.g.,
material components, mesh components). This is guaranteed to match what
the system originally collected.

### Before (red) / After (yellow):
<img width="838" alt="Screenshot 2025-02-21 at 10 46 17 AM"
src="https://github.com/user-attachments/assets/0e06b06d-7e91-4da5-a919-b843eb442a72"
/>
Log plot to highlight the long tail that this PR is addressing.
2025-07-09 06:23:44 +00:00
atlv
6fc4bc126d
Split out spot_light_world_from_view into a function in shadows.wgsl (#20050)
# Objective

- Improve readability

## Solution

- Split a function out

## Testing

- spotlight example works
2025-07-09 06:05:45 +00:00
Talin
aa87581cce
Change CoreWidgets plugin to plugin group. (#20036)
What it says on the tin. :)
2025-07-09 01:07:49 +00:00
Chris Russell
0ee937784e
Simplify self-edge checking in schedule building (#20015)
# Objective

Make the schedule graph code more understandable, and replace some
panics with `Result`s.

I found the `check_edges` and `check_hierarchy` functions [a little
confusing](https://github.com/bevyengine/bevy/pull/19352#discussion_r2181486099),
as they combined two concerns: Initializing graph nodes for system sets,
and checking for self-edges on system sets. It was hard to understand
the self-edge checks because it wasn't clear what `NodeId` was being
checked against! So, let's separate those concerns, and move them to
more appropriate locations.

Fix a bug where `schedule.configure_sets((SameSet, SameSet).chain());`
would panic with an unhelpful message: `assertion failed: index_a <
index_b`.

## Solution

Remove the `check_edges` and `check_hierarchy` functions, separating the
initialization behavior and the checking behavior and moving them where
they are easier to understand.

For initializing graph nodes, do this on-demand using the `entry` API by
replacing later `self.system_set_ids[&set]` calls with a
`self.system_sets.get_or_add_set(set)` method. This should avoid the
need for an extra pass over the graph and an extra lookup.

Unfortunately, implementing that method directly on `ScheduleGraph`
leads to borrowing errors as it borrows the entire `struct`. So, split
out the collections managing system sets into a separate `struct`.

For checking self-edges, move this check later so that it can be
reported by returning a `Result` from `Schedule::initialize` instead of
having to panic in `configure_set_inner`. The issue was that `iter_sccs`
does not report self-edges as cycles, since the resulting components
only have one node, but that later code assumes all edges point forward.
So, check for self-edges directly, immediately before calling
`iter_sccs`.

This also ensures we catch *every* way that self-edges can be added. The
previous code missed an edge case where `chain()`ing a set to itself
would create a self-edge and would trigger a `debug_assert`.
2025-07-08 18:09:45 +00:00
François Mockers
9bb41a8309
bevy_math: don't allow dead code (#20039)
# Objective

- `bevy_math` allows the `dead_code` lint on some private structs when
`alloc` is not enabled
- allowing lints is not allowed, we should use expect

## Solution

- Don't even compile the code if its expected to be dead instead of
allowing or expecting the lint
2025-07-08 17:46:01 +00:00
François Mockers
9b114a4936
enable syn/full in bevy_render_macros (#20034)
# Objective

- `bevy_render_macros` fails to build on its own:
```
error[E0432]: unresolved import `syn::Pat`
   --> crates/bevy_render/macros/src/specializer.rs:13:69
    |
13  |     DeriveInput, Expr, Field, Ident, Index, Member, Meta, MetaList, Pat, Path, Token, Type,
    |                                                                     ^^^
    |                                                                     |
    |                                                                     no `Pat` in the root
    |                                                                     help: a similar name exists in the module: `Path`
    |
note: found an item that was configured out
   --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/syn-2.0.104/src/lib.rs:485:15
    |
485 |     FieldPat, Pat, PatConst, PatIdent, PatLit, PatMacro, PatOr, PatParen, PatPath, PatRange,
    |               ^^^
note: the item is gated behind the `full` feature
   --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/syn-2.0.104/src/lib.rs:482:7
    |
482 | #[cfg(feature = "full")]
    |       ^^^^^^^^^^^^^^^^
```

## Solution

- Enable the `full` feature of `syn`
2025-07-08 17:08:20 +00:00
François Mockers
1cbd67f96a
formatting fix in bevy_remote cargo.toml (#20033)
# Objective

- bevy_log is not "others". it's part of Bevy

## Solution

- Move it
- Also use the same format as other Bevy dependency (path first) as I
use it in some regexes to run tests on the repo
2025-07-08 17:02:02 +00:00
andriyDev
09ccedd244
Clean up several miscellaneous uses of weak_handle. (#19408)
# Objective

- Related to #19024.

## Solution

- This is a mix of several ways to get rid of weak handles. The primary
strategy is putting strong asset handles in resources that the rendering
code clones into its pipelines (or whatever).
- This does not handle every remaining case, but we are slowly clearing
them out.

## Testing

- `anti_aliasing` example still works.
- `fog_volumes` example still works.
2025-07-08 06:45:40 +00:00
ickshonpe
5e3927ba48
UI gradients long hue paths fix (#20010)
# Objective

The false and true arguments for the select statement in `lerp_hue_long`
are misordered, resulting in it taking the wrong hue path:


![oklch-long-wrong-path](https://github.com/user-attachments/assets/68b733ab-be4b-4280-9346-4fdfccdb053a)

## Solution

Swap the arguments around.

Also fixed another case I found during testing. The hue was interpolated
even when it is undefined for one of the endpoints (for example in a
gradient from black to yellow). In those cases it shouldn't interpolate,
instead it should return the hue of the other end point.

## Testing

I added a `linear_gradient` module to the testbed `ui` example, run
with:
```
cargo run --example testbed_ui
```

In the linear gradients screen (press space to switch) it shows a column
of red to yellow linear gradients. The last gradient in the column uses
the OKLCH long path, which should look like this:


![okchlong-red-yellow](https://github.com/user-attachments/assets/23537ff4-f01a-4a03-8473-9df57b2bfaf1)

matching the same gradient in CSS:

https://jsfiddle.net/fevshkdy/14/

if the correct hue path is chosen.
2025-07-07 22:19:24 +00:00
AlephCubed
3aed85a88b
Rename send_event and similar methods to write_event (#20017)
Fixes: #18963
Follows up on: #17977
Adopts: #18966

In 0.16, `EventWriter::send` was renamed to `EventWriter::write`, but
many methods were missed (sorry about that). This completes that
refactor by renaming all `send` methods and internals.

| Old | New |

|-------------------------------------|--------------------------------------|
| `World::send_event` | `World::write_event` |
| `World::send_event_default` | `World::write_event_default` |
| `World::send_event_batch` | `World::write_event_batch` |
| `DeferredWorld::send_event` | `DeferredWorld::write_event` |
| `DeferredWorld::send_event_default` |
`DeferredWorld::write_event_default` |
| `DeferredWorld::send_event_batch` | `DeferredWorld::write_event_batch`
|
| `Commands::send_event` | `Commmands::write_event` |
| `Events::send` | `Events::write` |
| `Events::send_default` | `Events::write_default` |
| `Events::send_batch` | `Events::write_batch` |
| `RemovedComponentEvents::send` | `RemovedComponentEvents::write` |
| `command::send_event` | `commmand::write_event` |
| `SendBatchIds` | `WriteBatchIds` |

---------

Co-authored-by: shwwwa <shwwwa.dev@gmail.com>
2025-07-07 22:05:16 +00:00
Christian Hughes
fb5d8fd867
Make Parallel<T> more T: !Default accessible (#17943)
# Objective

`ThreadLocal::<T>::default()` doesn't require `T: Default`, so
`Parallel<T>` shouldn't require it either.

## Solution

- Replaced the `Default` derive with a manually specified impl.
- Added `Parallel::borrow_local_mut_or` as a non-`T: Default`-requiring
alternative to `borrow_local_mut`.
- Added `Parallel::scope_or` as a non-`T: Default`-requiring alternative
to `scope`.
2025-07-07 20:22:20 +00:00
Rob Parrett
2342e993ec
Bump typos to 1.34.0 (#20013)
# Objective

Closes #20006

## Solution

Bump `typos` and also fix the new typos detected

## Testing

CI
2025-07-07 20:15:06 +00:00
atlv
75f49bd335
Move IrradianceVolume to bevy_light (#20000)
# Objective

- Reunite it with its family

## Solution

- Immigration

## Testing

- irradiance_volumes example
2025-07-07 20:11:43 +00:00
atlv
e2810085a8
remove unused dependencies (#19998)
# Objective

- dont depend on things we dont need tp

## Solution

- just dont do it

## Testing

- 3d_scene runs
2025-07-07 20:10:33 +00:00
ickshonpe
5ea0e4004f
HSL and HSV interpolation for UI gradients (#19992)
# Objective

Add interpolation in HSL and HSV colour spaces for UI gradients.

## Solution
Added new variants to `InterpolationColorSpace`: `Hsl`, `HslLong`,
`Hsv`, and `HsvLong`, along with mix functions to the `gradients` shader
for each of them.

#### Limitations
* Didn't include increasing and decreasing path support, it's not
essential and can be done in a follow up if someone feels like it.

* The colour conversions should really be performed before the colours
are sent to the shader but it would need more changes and performance is
good enough for now.

## Testing

```cargo run --example gradients```
2025-07-07 20:08:51 +00:00
Zeenobit
12da4e482a
Add parent ID to the B0004 log message (#19980)
# Objective

Minor CL to add parent entity ID to the B0004 error message to improve
debugging.
2025-07-07 20:04:59 +00:00
JaySpruce
eb6afd26a1
Avoid early function invocation in EntityEntryCommands (#19978)
## Objective

Fixes #19884.

## Solution

- Add an internal entity command `insert_with`, which takes a function
returning a component and checks if the component would actually be
inserted before invoking the function.
- Add the same check to `insert_from_world`, since it's a similar
situation.
- Update the `or_insert_with`, `or_try_insert_with`, and `or_default`
methods on `EntityEntryCommands` to use the new command.

Since the function/closure returning the component now needs to be sent
into the command (rather than being invoked before the command is
created), the function now has `Send + 'static` bounds. Pretty typical
for command stuff, but I don't know how/if it'll affect existing users.

---------

Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
2025-07-07 20:02:55 +00:00
TimJentzsch
b0df3fb4d0
Document why examples are disabled on the web, pass 1 (#19262)
# Objective

With the Bevy CLI, we now have an easy way to locally test if examples
work on the web.
We should start to explicitly document why examples don't work on the
web to keep track and to ensure that as many examples are enabled as
possible.

## Solution

- Go through the examples with `wasm = false` and check if they really
don't work
- If they don't work, try to figure out why by looking through the code
and announcement posts (we need better docs for this please) and add a
comment explaining it
- The `lightmap` example seemed to work without problems, so I enabled
it

## Testing

Install the [Bevy CLI](https://github.com/TheBevyFlock/bevy_cli) and
run:

```
bevy run --example={example_name} web --open
```

# Future Work

- There are about 100 more examples with `wasm = false` that also need
to be documeneted
- Also improve the documentation on the related features/plugins/types
to make it easier for users to determine what they can use

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
2025-07-07 20:02:21 +00:00
stevehello166
6729208d39
Implement display for direction (#19942)
# Objective
To implement fmt::Display for the direction types. The reason that this
would be a good addition is that I often find myself using println! to
debug things with directions and adding the extra ":?" was getting a
little annoying. It would also be better for any potential CLI apps that
might need to output a direction.

## Solution
Copied glam's implementation of Display for each length of direction.
I.E Vec3's display for Dir3.

## Testing

- Did you test these changes? If so, how?
Yes, I wrote a little script that printed out the different directions
and compared it to their vector counterparts.
Here it is if anyone's interested
```
use bevy_math::*;

fn main() {
    let dir2 = Dir2::from_xy(0.0, 1.0).unwrap();
    let dir3 = Dir3::from_xyz(0.0, 1.0, 0.0).unwrap();
    let dir3a = Dir3A::from_xyz(0.0, 1.0, 0.0).unwrap();
    let dir4 = Dir4::from_xyzw(0.0, 1.0, 0.0, 0.0).unwrap();
    let vec2 = Vec2::new(0.0, 1.0);
    let vec3 = Vec3::new(0.0, 1.0, 0.0);
    let vec4 = Vec4::new(0.0, 1.0, 0.0, 1.0);
    println!("{dir2} {dir3} {dir3a} {dir4}");
    println!("{vec2}, {vec3}, {vec4}")
}
```
- Are there any parts that need more testing?
Perhaps
2025-07-07 20:00:37 +00:00
eugineerd
3b6d01972b
Unify filtering by id in EntityClonerBuilder (#19977)
# Objective
#19649 introduced new `*_if_new` and `*_by_bundle_id_*` variations to
`EntityClonerBuilder` filtering functionality, which resulted in
increase in method permutations - there are now 8 allow variants to
support various id types and 2 different insert modes.

## Solution
This PR introduces a new trait `FilterableIds` to unify all id types and
their `IntoIterator` implementations, which is somewhat similar to
`WorldEntityFetch`. It supports `TypeId`, `ComponentId` and `BundleId`,
allowing us to reduce the number of `allow` methods to 4: `allow`,
`allow_if_new`, `allow_by_ids`, `allow_by_ids_if_new`. The function
signature is a bit less readable now, but the docs mention types that
can be passed in.

## Testing
All existing tests pass, performance is unchanged.

---------

Co-authored-by: urben1680 <55257931+urben1680@users.noreply.github.com>
2025-07-07 20:00:37 +00:00
Nicholas Nethercote
d80078cf2d
bevy_reflect: Introduce reflect_clone_and_take. (#19944)
# Objective

There is a pattern that appears in multiple places, involving
`reflect_clone`, followed by `take`, followed by `map_err` that produces
a `FailedDowncast` in a particular form.

## Solution

Introduces `reflect_clone_and_take`, which factors out the repeated
code.

## Testing

`cargo run -p ci`

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-07-07 19:57:29 +00:00
Nicholas Nethercote
f1df61e458
bevy_reflect: Avoid trait bounds on non-generic types (#19929)
# Objective

All the derived reflection methods currently have multiple trait bounds
on non-generic field types, which serve no purpose. The are emitted
because "emit bounds on all fields" is easier than "emit bounds on
fields that need them". But improving things isn't too hard.

Similarly, lots of useless `Any + Send + Sync` bounds exist on
non-generic types.

Helps a lot with #19873.

## Solution

Remove the unnecessary bounds by only emitting them if the relevant type
is generic.

## Testing

I used `cargo expand` to confirm the unnecessary bounds are no longer
produced.

`-Zmacro-stats` output tells me this reduces the size of the `Reflect`
code produced for `bevy_ui` by 21.2%.
2025-07-07 19:53:14 +00:00
Wuketuke
f09c3a1a56
doc improvement for StateTransition (#19597)
Fixes #19594
The exact problem is described in that issue.
I improved the docs to guide anyone who has the the same issue I had.
I kept myself minimal, since the problem is relatively niche, hopefully
it will be enough if anyone else has that problem
2025-07-07 19:51:46 +00:00
Wuketuke
4865c538b1
SpatialListener now requires a Transform (#19357)
I noticed that the `SpatialListener` asks to have a `Transform`
attached. It seemed weird that we didnt just use a require macro, so i
went ahead and did that
I also tweaked the system that plays audio to use a `&GlobalTransform`
instead of an `Option<&GlobalTransform>`
2025-07-07 19:48:57 +00:00
Fallible Things
3ad7a75781
Explanation for the '3d shapes' example (#19295)
[Explanation](https://bevyengine.org/learn/contribute/helping-out/explaining-examples/)
for the 3d shapes example.

This shares a lot of detail with the [2d
shapes](https://github.com/bevyengine/bevy/pull/19211) example, so it's
similar in structure. The explanation for why asset handles are not
components has been copied over for now with minor adjustment, I'll do
another editing pass on this to make it match the surrounding context
and focus before taking it out of drafts.

---------

Co-authored-by: theotherphil <phil.j.ellison@gmail.com>
Co-authored-by: Carter Weinberg <weinbergcarter@gmail.com>
2025-07-07 19:47:19 +00:00
Lucas Franca
80b059c815
Extract members of PickingPlugin and PointerInputPlugin into new types (#19078)
# Objective

`PickingPlugin` and `PointerInputPlugin` were kinda weird being both a
plugin and a resource.

## Solution

Extract the resource functionality of `PickingPlugin` and
`PointerInputPlugin` into new resources

## Testing

`mesh_picking` and `sprite_picking`

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
2025-07-07 19:40:25 +00:00
Gilles Henaux
ca25a67d0d
Fix the extended_material example on WebGL2 (#18812)
# Objective

- Fixes #13872 (also mentioned in #17167)

## Solution

- Added conditional padding fields to the shader uniform

## Alternatives

### 1- Use a UVec4

Replace the `u32` field in `MyExtension` by a `UVec4` and only use the
`x` coordinate.

(This was the original approach, but for consistency with the rest of
the codebase, separate padding fields seem to be preferred)

### 2- Don't fix it, unlist it

While the fix is quite simple, it does muddy the waters a tiny bit due
to `quantize_steps` now being a UVec4 instead of a simple u32. We could
simply remove this example from the examples that support WebGL2.

## Testing

- Ran the example locally on WebGL2 (and native Vulkan) successfully
2025-07-07 19:34:12 +00:00
Greeble
0f75142560
Add test for invalid skinned meshes (#18763)
## Objective

Add a test that would have caught #16929 and #18712.

## Solution

The PR adds a `test_invalid_skinned_mesh` example that creates various
valid and invalid skinned meshes. This is designed to catch panics via
CI, and can be inspected visually. It also tests skinned meshes + motion
blur.


![417958065-37df8799-b068-48b8-87a4-1f144e883c9c](https://github.com/user-attachments/assets/22b2fa42-628b-48a4-9013-76d6524cecf5)

The screenshot shows all the tests, but two are currently disabled as
they cause panics. #18074 will re-enable them.

### Concerns

- The test is not currently suitable for screenshot comparison.
- I didn't add the test to CI. I'm a bit unsure if this should be part
of the PR or a follow up discussion.
- Visual inspection requires understanding why some meshes are
deliberately broken and what that looks like.
- I wasn't sure about naming conventions. I put `test` in the name so
it's not confused with a real example.

## Testing

```
cargo run --example test_invalid_skinned_mesh
```

Tested on Win10/Nvidia, across Vulkan, WebGL/Chrome, WebGPU/Chrome.
2025-07-07 19:28:52 +00:00