Commit Graph

7342 Commits

Author SHA1 Message Date
andriyDev
2824bd5f6e
Use RenderStartup in bevy_sprite. (#20147)
# Objective

- Progress towards #19887.

## Solution

- Convert FromWorld implementations into systems.
- Move any resource "manipulation" from `Plugin::finish` to systems.
- Add `after` dependencies to any uses of these resources (basically all
`SpritePipeline`).

## Testing

- Ran the `sprite`, and `mesh2d_manual` example and it worked.
2025-07-15 06:30:34 +00:00
Christian Hughes
2be3bc5310
Improve node encapsulation in ScheduleGraph (#20119)
# Objective

- Part of #20115

We want to encapsulate each part of `ScheduleGraph` into its own
specific struct to make parts of it easier to reuse and maintain.

## Solution

- Pulled `ScheduleGraph::systems` and `ScheduleGraph::system_conditions`
into a `Systems` struct and added a field for this new struct to
`ScheduleGraph`
- Broke up `ScheduleGraph::uninit` into `Systems::uninit` and
`SystemSets::uninit` to eliminate `ScheduleGraph`'s direct field access
of these types
- Removed node and condition accessors from `ScheduleGraph`; the same
operations are now available on `Systems` and `SystemSets` instead
(accessible via their `pub` fields on `ScheduleGraph`)
- Moved `Systems`, `SystemSets`, `SystemNode`, `SystemWithAccess`, and
`ConditionWithAccess` into a separate file.

## Testing

Added two new tests covering the API surface of `Systems` and
`SystemSets`, respectively.

---------

Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
2025-07-15 06:29:52 +00:00
Christian Hughes
0747b66602
ReadOnlySystem diagnostics and type alias (#19138)
# Objective

- Improve usability of read-only systems.

## Solution

- Added `on_unimplemented` diagnostics for types/functions that aren't
read-only systems.
- Added `BoxedReadOnlySystem` type alias, similar to `BoxedSystem`.

## Testing

Can/should we test these diagnostics?
2025-07-15 00:14:06 +00:00
eugineerd
3caca428c0
allow EntityCloner to move components without Clone or Reflect (#20065)
# Objective
Fix #18079 

## Solution
- `EntityCloner` can now move components that don't have `Clone` or
`Reflect` implementation.
- Components with `ComponentCloneBehavior::Ignore` will not be moved.
- Components with `ComponentCloneBehavior::Custom` will be cloned using
their defined `ComponentCloneFn` and then removed from the source entity
to respect their `queue_deferred` logic.
- Relationships still need to be `Clone` or `Reflect` to be movable.
- Custom relationship data is now correctly preserved when cloned or
moved using `EntityCloner`.

## Testing
- Added new tests for moving components

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-07-14 22:33:01 +00:00
onbjerg
554bc7b0d4
Document repeating timer tick behavior (#20137)
# Objective

Closes #20132 

## Solution

I found docs describing the behavior elsewhere in Bevy, which I pulled
in to the main `Timer` docs:
b01de70bdd/crates/bevy_time/src/common_conditions.rs (L27-L35)

I also restructured the docs a little bit.
2025-07-14 22:31:31 +00:00
ickshonpe
2cb8450fa4
Rename the InterpolationColorSpace variants to match Color. (#20142)
# Objective

The names of the variants of `InterpolationColorSpace` don't match the
corresponding `Color` variants, which could be potentially confusing.
For instance, `Color` has an `Oklaba` variant, in
`InterpolationColorSpace` it's called `OkLab`.

## Solution

Rename variants of `InterpolationColorSpace` to mirror the variants of
Color.
2025-07-14 22:30:43 +00:00
Sieluna
6edfe1d39b
Link ComponentIdFor in the ComponentId related docs (#20127)
# Objective

Fixes https://github.com/bevyengine/bevy/issues/19535. Improve
interoperability of type documentation to make it easier for users to
find related types

## Solution

- Add a reference to
[`ComponentIdFor`](crate::component::ComponentIdFor) in the
`component_id` function documentation in
`crates/bevy_ecs/src/world/mod.rs`
- Add a reference to [`ComponentIdFor`](super::ComponentIdFor) in the
`component_id` function documentation in
`crates/bevy_ecs/src/component/info.rs`

## Testing

- Verify documentation generation: `cargo doc`
- Check the validity of cross-reference links in the documentation
- Confirm that the documentation generated by rustdoc can correctly jump
to the type definition of `ComponentIdFor`
2025-07-14 21:59:08 +00:00
Nicholas Nethercote
b8072864aa
Streamline GetOwnership/FromArg/IntoReturn (#20126)
# Objective

Three impls are generated for each of these traits when the
`reflect_functions` feature is enabled.

Helps with #19873.

## Solution

Two of the three (the `&T` and `&mut T` ones) can be avoided by instead
providing blanket impls. The impl for `T` remains.

## Testing

I checked the output via `cargo expand`.

According to `-Zmacro-stats`, the size of the `Reflect` code generate
for `bevy_ui` drops by 10.4%.
2025-07-14 21:57:34 +00:00
coolcatcoder
c85ab89615
Allow NotShadowCaster to be used with HierarchyPropagatePlugin. (#20120)
# Objective

Allow NotShadowCaster to be used with HierarchyPropagatePlugin.

## Solution

Implements Clone and PartialEq for NotShadowCaster.
2025-07-14 21:55:12 +00:00
Emerson Coskey
7447b0ab97
Mini Blit refactor (#20118)
# Objective

- Clean up usage of BlitPipeline

## Solution

- add `create_bind_group` method
- adjust some field and variable names for clarity

## Testing

- ran 3d_scene
2025-07-14 21:50:56 +00:00
Pete Hayman
6671575eb0
feat: implement clone for IntoPipeSystem (#20108)
# Objective

Implement `Clone` for `IntoPipeSystem`, allowing for `T: IntoSystem +
Clone` patterns.


## Precedence

Same clone implementation/docs as `CombinatorSystem`
2025-07-14 21:38:51 +00:00
Tim
4e9e78c31e
Split BufferedEvent from Event (#20101)
# Objective

> I think we should axe the shared `Event` trait entirely
It doesn't serve any functional purpose, and I don't think it's useful
pedagogically
@alice-i-cecile on discord

## Solution

- Remove `Event` as a supertrait of `BufferedEvent`
- Remove any `Event` derives that were made unnecessary
- Update release notes

---------

Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net>
2025-07-14 21:31:48 +00:00
ickshonpe
b47f6e8901
Constify gradients helper functions (#20098)
# Objective

Constify some of the helper functions in the UI's `gradients` module.
2025-07-14 21:27:43 +00:00
BD103
a35a9cb418
Fix link to bevy_solari logo (#20097)
# Objective

The `bevy_solari` logo doesn't load in the
[dev-docs](https://dev-docs.bevy.org/bevy/solari/index.html):

<img width="1572" height="594" alt="image"
src="https://github.com/user-attachments/assets/c662402a-a729-4982-bb7f-add072742f4c"
/>

This is because the link to the image,
<https://raw.githubusercontent.com/bevyengine/bevy/assets/branding/bevy_solari.svg>,
returns a 404 not found.

## Solution

Fix the link to point to
<https://raw.githubusercontent.com/bevyengine/bevy/refs/heads/main/assets/branding/bevy_solari.svg>!

![Solari
Logo](https://raw.githubusercontent.com/bevyengine/bevy/refs/heads/main/assets/branding/bevy_solari.svg)

## Testing

Open up the crate page for `bevy_solari` and make sure the image loads
:)

```sh
cargo doc -p bevy_solari --open --no-deps
```
2025-07-14 21:25:44 +00:00
Tim
5d6d6343b9
Add doc examples to viewport_to_world(_2d) (#20096)
# Objective

Add doc examples to `viewport_to_world` and `viewport_to_world_2d`.
With `Single` and let chains these can be very concise now :) 

## Rendered:

<img width="1427" height="581" alt="image"
src="https://github.com/user-attachments/assets/e9de79fe-545f-4dd9-b9c4-77c8cb22de74"
/>

<img width="1427" height="581" alt="image"
src="https://github.com/user-attachments/assets/8c1d52ed-3423-4827-8120-c7720a79309c"
/>

I changed my mind on how much to limit the decimal places after taking
this screenshot. Hence the `:.0` instead of the actual `:.2`
2025-07-14 21:24:28 +00:00
Martin Lysell
b91a233acf
Fix AmbientLight::affects_lightmapped_meshes not working (#20083)
# Objective

Fix lightmapped materials not respecting the
AmbientLight::affects_lightmapped_meshes setting.

NOTE: This only makes the setting work on the forward renderer. Making
it work on the deferred renderer would probably require encoding more
information in the g-buffer or similar. Please advise if I missed some
obvious way to get it working on deferred.

## Solution

- Make ambient light conditionally applied depending on the
affects_lightmapped_meshes setting when material mesh i lightmapped
- Remove what looks to be leftover `Lights` (wgsl) members:
`environment_map_smallest_specular_mip_level`,
`environment_map_intensity`. (These where not present in the rust
equivalent `GpuLights` and was not used in the wgsl code)

## Open Questions
- Ambient light is also blended into the transmitted light if
`DIFFUSE_TRANSMISSION` is enabled on the material. Should that also be
guarded by the same conditional as the indirect contribution?

## Testing

Ran a modified version of the lightmaps example, where there is a bright
red ambient light added and the small cube do not have a lightmap added
(To be able to see ambient light applied to meshes without lightmaps)

---

## Showcase
### Main: Lightmap example with bright red ambient, small box have no
lightmap
<img width="613" height="601" alt="Main"
src="https://github.com/user-attachments/assets/a3f206d7-5a1e-4590-8c40-69d5c6e06ce0"
/>

(All meshes get ambient light even when `affects_lightmapped_meshes =
false`)

### This PR: Lightmap example with bright red ambient, small box have no
lightmap
<img width="612" height="602" alt="With fix"
src="https://github.com/user-attachments/assets/d1a149a5-8994-4572-909f-8788ba2c38fc"
/>

(Only the small box get ambient light when `affects_lightmapped_meshes =
false`)
2025-07-14 21:13:10 +00:00
Lynn
c4407b1e03
Rhombus sampling (#20082)
# Objective

- Implement `ShapeSample for Rhombus`

## Testing

- The results can be verified visually. 

---

## Showcase
### Boundary
<img width="855" height="545" alt="image"
src="https://github.com/user-attachments/assets/0cdb16a8-f26a-4f13-a5dc-dd27e251a6d0"
/>

### Interior
<img width="736" height="512" alt="Screenshot 2025-07-11 143336"
src="https://github.com/user-attachments/assets/1ba6b2af-4d89-485a-9256-f02b4e2043a7"
/>
2025-07-14 21:05:42 +00:00
Martin Lysell
7db64a7b3b
Fix anisotropy not working when material is lit by environment map light (#20077)
Fixes objects being lit by environment map light not having the
anisotropy effect applied correctly. The contribution of light from the
environment map with anisotropy is calculated but immediately discarded.
Instead what is applied is the regular environment map contribution
(calculated without anisotropy) that happen right after.

This patch fixes the logic here to what I think is the intended one.
Only calculate contribution once, with or without anisotropy depending
on shader specialization.

## Solution

- Properly apply normal modification if anisotropy is enabled.
- Remove duplicate environment map light calculation

## Testing
Tested this by running the anisotropy example and comparing main vs PR
results. See images below.

---

## Showcase

Main:
<img width="580" height="503" alt="Main-AnisoEnabled"
src="https://github.com/user-attachments/assets/47471a12-60cd-48ba-a32e-60086b6d162a"
/>

PR:
<img width="592" height="509" alt="WithFix-AnisoEnabled"
src="https://github.com/user-attachments/assets/e1f6b82c-1bac-40e1-8925-3abece05f406"
/>


</details>
2025-07-14 21:03:02 +00:00
Sven Niederberger
3ce2f46ae5
GpuReadbackPlugin: Allow reading only a part of a buffer (#20133)
# Objective

- So far only full buffer reads were supported. This adds the ability to
read a part of a buffer.

## Solution

- Allow passing in a start offset and a number of bytes to read when
creating the `Readback` component.
- I also removed the unused `src_start` and `dst_start` fields from
`ReadbackSource` as they were always 0.

## Testing

- Did you test these changes? If so, how?

I extended the example to also demonstrate partial reads.

- Are there any parts that need more testing?

Can't think of any.

- How can other people (reviewers) test your changes? Is there anything
specific they need to know?

Run the `gpu_readback` example. It now also reads and prints a partially
read buffer.

- If relevant, what platforms did you test these changes on, and are
there any important ones you can't test?

Only tested on Linux.

---

## Showcase

Example output:

<details>
  <summary>Click to view showcase</summary>

```
2025-07-14T14:05:15.614876Z  INFO gpu_readback: Buffer [257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272]
2025-07-14T14:05:15.614921Z  INFO gpu_readback: Buffer range [261, 262, 263, 264, 265, 266, 267, 268]
2025-07-14T14:05:15.614937Z  INFO gpu_readback: Image [257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
```

</details>
2025-07-14 21:01:16 +00:00
atlv
e13e259436
Fix core widgets unconditionally enabling bevy_ui_picking_backend (#20055)
# Objective

- Fixes #19742

## Solution

- Initially I made it an optional feature on bevy_core_widgets and piped
it through to bevy_internal, but then I realized that its not actually
directly reference in the crate so its safe to just remove it.
2025-07-14 20:55:42 +00:00
atlv
e0383a0b96
Add zstd release note (#20053)
# Objective

- Add a release note for the new zstd backend.
- Doing so, I realized it was really cumbersome to enable this feature
because we default-enable ruzstd AND make it take precedence if both are
enabled. We can improve ux a bit by making the optional feature take
precedence when both are enabled. This still doesnt remove the unneeded
dependency, but oh well.

Note: it would be nice to have a way to make zstd_c not do anything when
building wasm, but im not sure theres a way to do that, as it seems like
it would need negative features.

---------

Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
2025-07-14 20:53:26 +00:00
Giacomo Stevanato
89c3a979e6
Prevent TOCTOU bugs in ComponentsQueuedRegistrator (#20016)
# Objective

- Fix #20014

## Solution

- Don't make the `force_register_` family of functions always enqueue of
the component/resource; instead have them check again whether it was
already queued or not.

## Testing

- I added a small regression test but it's non-deterministic: if the bug
is fixed it will always pass, but if the bug is presen then it has a
(hopefully small) chance of passing. On my PC it failed after ~100
iterations, so hopefully 1000 is enough in CI (assuming it doesn't have
single core runners...)

---------

Co-authored-by: JaySpruce <jsprucebruce@gmail.com>
2025-07-14 20:41:18 +00:00
andriyDev
6e3739ac96
Use RenderStartup for bevy_pbr for some basic cases. (#19999)
# Objective

- Progress towards #19887.

## Solution

- For cases that don't need to conditionally add systems, we can just
replace FromWorld impls with systems and then add those systems to
`RenderStartup`.

## Testing

- I ran the `lightmaps`, `reflection_probes`, `deferred_rendering`,
`volumetric_fog`, and `wireframe` examples.
2025-07-14 20:28:03 +00:00
Nicholas Nethercote
c994bdf71a
bevy_reflect: Use active_types instead of active_fields where appropriate (#19922)
# Objective

Follow on fixes for #19876, using `active_types` instead of
`active_fields` where appropriate.

Helps a tiny bit with #19873.

## Solution

- Describe the solution used to achieve the objective above.

## Testing

I checked the output of `cargo expand` and ran `cargo run -p ci`.
2025-07-14 20:24:46 +00:00
Greeble
87db37695c
Fix a NestedLoader code path that failed to use its meta transform (#19117)
## Solution

While poking around `NestedLoader` I noticed that one code path fails to
pass on the loader's meta transform.

```diff
- .get_or_create_path_handle(path, None)
+ .get_or_create_path_handle(path, self.meta_transform)
```

This seems like a simple oversight - all other code paths pass on the
meta transform where possible - although I'm not familiar enough with
the asset system to be 100% sure. It was introduced when asset loaders
were changed to use the builder pattern (#13465).

Unfortunately I couldn't find an example that actually hits this code
path. So I don't have a good test case, and I don't know if any users
have experienced it as a bug.

## Testing

```
cargo test -p bevy_asset
```

Also tested various examples - `testbed_2d`, `testbed_3d` and everything
in `examples/asset`.
2025-07-14 20:15:47 +00:00
RuelYasa
9751db4d6c
Fixing a crash when minimizing a window with custom viewport. (#16704) (#18916)
# Objective

Fix a crash when minimizing a window. (#16704) It happens when the
window contains Camera with a custom Viewport.

## Solution

Remove ExtractedCamera when the corresponding camera in main world has
zero target size. It indicates that the window is minimized.

## Testing

Tested in Windows 11.
Previously the split_screen example crashes when the window is
minimized; and with this change, it would not crash. Other behaviors
remain unchanged.
2025-07-14 20:11:55 +00:00
Giacomo Stevanato
8777dd4144
Split bundle.rs (#20088)
# Objective

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

## Solution

- Split `bundle.rs` into the following:
  - `bundle/mod.rs` with the main traits and their documentation
- `bundle/impls.rs` with the main trait implementations for components
and tuples
- `bundle/info.rs` with `BundleInfo` and other types for managing bundle
informations metadata
- `bundle/insert.rs` with code for inserting a bundle into an existing
entity
- `bundle/remove.rs` with code for removing a bundle from an existing
entity
- `bundle/spawner.rs` with code for inserting a bundle on a fresh entity
  - `bundle/tests.rs` with code for tests

## Reviewer notes

I suggest reviewing with `--color-moved`, possibly commit-by-commit, in
order to quickly verify that most lines were only moved and not changed.
2025-07-14 18:13:51 +00:00
Jan Hohenheim
9edf538643
Fix glTF light orientation (#20122)
# Objective

- Extracted from https://github.com/bevyengine/bevy/pull/20099
- Turns out glTF also uses its viewport coordinate system for lights, so
let's account for that

## Solution

- Use the same branch for lights as for cameras when importing glTFs

## Testing

- Ran a dedicated Blender test scene to verify that this is the correct
behavior.
2025-07-14 13:20:18 +00:00
Nicholas Nethercote
33bed5dd70
bevy_reflect: remove unnecessary const _ around TypePath impl (#19902)
# Objective

Derived `TypePath` impls have a `const _` block in order to hold a `use
alloc::string::ToString` import. But that import is useless.

Avoiding it helps with https://github.com/bevyengine/bevy/issues/19873.

## Solution

Remove the `use` and `const _`.

## Testing

I used cargo expand to confirm the `const _ ` is no longer produced.

`-Zmacro-stats` output tells me this reduces the size of the `Reflect`
code produced for `bevy_ui` from 1_880_486 bytes to 1_859_634 bytes, a
1.1% drop.
2025-07-13 22:38:19 +00:00
Chamaloriz
d83bae4417
FIX - RelativeCursorPosition Changed<> query filter (#20102)
## Problem

This pseudocode was triggering constantly, even with the Changed<> query
filter.

```rust
pub fn check_mouse_movement_system(
    relative_cursor_positions: Query< &RelativeCursorPosition, (Changed<RelativeCursorPosition>, With<Button>)>,
) {}
```

## Solution

- Added a check to prevent updating the value if it hasn't changed.

---------

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
2025-07-13 19:44:40 +00:00
JMS55
84936cad55
Fix visibility (re)use in Solari DI (#20113)
# Objective
Fixes the re(use) of visibility in Solari's ReSTIR DI. 

The paper I based things off of didn't (seem) to use visibility in their
resampling
https://yusuketokuyoshi.com/papers/2024/Efficient_Visibility_Reuse_for_Real-time_ReSTIR_(Supplementary_Document).pdf,
only shading, but factoring it into the resampling improves things a
lot.

---

## Showcase
Before:
<img width="2564" height="1500" alt="image"
src="https://github.com/user-attachments/assets/15fa7941-ab68-47bc-9bbc-42ca55359046"
/>

After: 
<img width="2564" height="1500" alt="image"
src="https://github.com/user-attachments/assets/6fe52ed0-7832-41c1-b1cd-e8c8d9825e51"
/>
2025-07-13 19:33:09 +00:00
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
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
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