Commit Graph

9326 Commits

Author SHA1 Message Date
Arkitu
c6b743908c remove forgotten dbg
Some checks failed
Deploy Docs / build-and-deploy (push) Has been cancelled
Example Run / run-examples-macos-metal (push) Has been cancelled
Example Run / run-examples-linux-vulkan (push) Has been cancelled
Example Run / run-examples-on-windows-dx12 (push) Has been cancelled
Example Run / Compare Macos screenshots (push) Has been cancelled
Example Run / Compare Linux screenshots (push) Has been cancelled
Example Run / Compare Windows screenshots (push) Has been cancelled
2025-07-18 21:44:23 +02:00
Arkitu
b276c9e3df fix interpolation for pbr
Some checks are pending
Deploy Docs / build-and-deploy (push) Waiting to run
Example Run / run-examples-macos-metal (push) Waiting to run
Example Run / Compare Macos screenshots (push) Blocked by required conditions
Example Run / run-examples-linux-vulkan (push) Waiting to run
Example Run / Compare Linux screenshots (push) Blocked by required conditions
Example Run / run-examples-on-windows-dx12 (push) Waiting to run
Example Run / Compare Windows screenshots (push) Blocked by required conditions
2025-07-18 21:41:48 +02:00
Arkitu
08459422f9 add flat color and normal interpolation to standard material
Some checks are pending
Deploy Docs / build-and-deploy (push) Waiting to run
Example Run / run-examples-macos-metal (push) Waiting to run
Example Run / Compare Macos screenshots (push) Blocked by required conditions
Example Run / run-examples-linux-vulkan (push) Waiting to run
Example Run / Compare Linux screenshots (push) Blocked by required conditions
Example Run / run-examples-on-windows-dx12 (push) Waiting to run
Example Run / Compare Windows screenshots (push) Blocked by required conditions
2025-07-18 20:03:26 +02:00
Carter Anderson
877d278785
Remove unnecessary + use<> (#20180)
# Objective

Including `use<>` where it is not needed is abhorrent to my
sensibilities

## Solution

Begone foul demon!
2025-07-17 21:36:24 +00:00
Conner Petzold
ebf6bf6ea9
TilemapChunk single quad; TileData (color/visibility) (#19924)
# Objective

- Use a single quad to render a TilemapChunk
- Add support for tile color and visibility

## Testing

- Tested using example -- there doesn't appear to be any visual tile
bleeding or rounding issues. Open to ideas on further testing
2025-07-17 19:37:40 +00:00
Chris Russell
25cb339a12
Don't ignore default query filters for EntityRef or EntityMut (#20163)
# Objective

Don't ignore default query filters for `EntityRef` or `EntityMut`.

Currently, `Query<EntityRef>` will include entities with a `Disabled`
component, even though queries like `Query<()>` or `Query<Entity>` would
not. This was noticed in
https://github.com/bevyengine/bevy/pull/19711#discussion_r2205981065.

## Solution

Change `Access::contains` to completely ignore read access and just look
at filters and archetypal access. Filters covers `With`, `Without`, `&`,
and `&mut`, while archetypal covers `Has` and `Allows`.

Note that `Option<&Disabled>` will no longer count as a use of
`Disabled`, though.
2025-07-17 19:23:41 +00:00
Waridley
9e1e8bc1bc
Add angle-weighted smooth normals implementation (#18383) (#18552)
# Objective

Closes #18383 

## Solution

Given the 2 votes (me and @komadori ) for making angle-weighted normals
the default, I went ahead and did so, moving the face-weighted
implementation to the new `Mesh::compute_face_weighted_normals` method.
I factored out the common code between both into
`Mesh::compute_custom_smooth_normals`, which I went ahead and made
public to make it easier for users to add any other weighting methods
they might come up with.

If any of these decisions are undesirable for any reason, please let me
know and I will gladly make modifications.

## Testing & Showcase

I made a demo that exaggerates the difference at
[Waridley/bevy_smooth_normals_comparison](https://github.com/Waridley/bevy_smooth_normals_comparison).
Screenshots included in the readme.

Another way it could be demonstrated is via scaling a mesh along its
normals, like for generating outline meshes with inverted faces. I'd be
willing to make a demo for that as well.

I also edited and renamed the `compute_smooth_normals` tests to use
face-weighted normals, and added a new test for angle-weighted ones
which validates that all normals of a unit cube have each component
equal to `(±1 / √3) ± f32::EPSILON`.

## Migration Guide

#16050 already did not mention a migration guide, and it is not even in
a stable release yet. If this lands in a 0.16 RC, updating from RC1
would probably not require any changes in the vast majority of cases,
anyway. If someone really needs face-weighted normals, they can switch
to `.compute_face_weighted_normals()` or
`.with_computed_face_weighted_normals()`. And if for some reason they
really liked the old count-weighted implementation from 0.15, there is
an example in the docs for `compute_custom_smooth_normals`.
2025-07-17 19:23:30 +00:00
Pnoenix
f964ee1e3a
Expand MergeMeshError to include IncompatiblePrimitiveTopology variant (#18561)
# Objective

Fix #18546 by adding a variant to `MergeMeshError`, for incompatible
primitive topologies.

## Solution

Made `MergeMeshError` into an enum with two variants;
`IncompatibleVertexAttributes` and `IncompatiblePrimitiveTopology`.
Added an if statement in `Mesh::merge` to check if the
`primitive_topology` field of `self` matches `other`.
Also renamed `MergeMeshError` to `MeshMergeError` to align with the two
other `MeshSomethingError`'s.

## Testing

Didn't do any.
2025-07-16 20:37:58 +00:00
Steve Alexander
713acc2e6d
Change event to event_key where it refers to an EventKey (#20060)
# Objective

The ECS code to do with Observers was recently refactored to use an
`EventKey` newtype. On reading through the PR, I was a bit confused that
sometimes a variable called `event` refers to an `Event` and sometimes
it refers to an `EventKey`. I think the code is clearer when `event`
refers to an `Event` and `event_key` refers to an `EventKey`.

## Solution

This PR renames some uses of `event` to `event_key`.

## Testing

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

I ran `cargo run -p ci -- tests`

- Are there any parts that need more testing?

No

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

No.

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

Probably not relevant, but MacOS.

---------

Co-authored-by: Steve Alexander <steve.alexander@priva.com>
2025-07-16 18:19:30 +00:00
tomaspecl
2bcd85421e
Documentation improvement system_param.rs (#20157)
# Objective
Improvement of the documentation for SystemParam derive section so that
it mentions how to use a Query<&SomeComponent> as a SystemParam for a
struct that should have #[derive(SystemParam)].

## Solution
Added the documentation

---

## Showcase
the previous documentation
```rust
Query<'w, 's, Entity>,
Res<'w, SomeResource>,
ResMut<'w, SomeOtherResource>,
Local<'s, u8>,
Commands<'w, 's>,
EventReader<'w, 's, SomeEvent>,
EventWriter<'w, SomeEvent>
```
the new documentation
```rust
Query<'w, 's, Entity>,
Query<'w, 's, &'static SomeComponent>,  <================== the new thing
Res<'w, SomeResource>,
ResMut<'w, SomeOtherResource>,
Local<'s, u8>,
Commands<'w, 's>,
EventReader<'w, 's, SomeEvent>,
EventWriter<'w, SomeEvent>
```
2025-07-16 17:58:18 +00:00
BigWingBeat
e7c14bd06b
Add EntityWorldMut::(try_)resource_scope (#20162)
# Objective

Fixes #20139

## Solution

Implement the methods, and leverage them where applicable

## Testing

Added unit tests

---

## Showcase

```rust
let id = entity_world_mut.id();
let world = entity_world_mut.into_world_mut();
world.resource_scope::<_, _>(|world, res| {
    let entity_world_mut = world.entity_mut(id);
    /* ... */
});
```

becomes

```rust
entity_world_mut.resource_scope::<_, _>(|entity, res| {
    /* ... */
});
```
2025-07-16 17:37:25 +00:00
robtfm
d28d18e2ff
fix crash in light textures example (#20161)
# Objective

scaling the point light to zero caused a crash

## Solution

clamp the scale for all the lights
2025-07-16 16:42:40 +00:00
Tyler Critchlow
3fc49f00c1
Preconvert colors before sending to shader (#20074)
# Objective

- Fixes #20008 - Preconvert colors before sending them to the UI
gradients shader for better performance

  ## Solution

- Modified `prepare_gradient` in `gradient.rs` to convert colors from
`LinearRgba` to `Srgba` on the CPU before sending to the GPU
- Updated the gradient shader to remove per-pixel color space
conversions since colors are now pre-converted
  - Added documentation to clarify that vertex colors are in sRGB space

This optimization reduces the number of power operations per pixel from
3 to 1:
- **Before**: Convert start color to sRGB, convert end color to sRGB,
mix, convert back to linear (3 pow operations per pixel)
- **After**: Colors pre-converted on CPU, mix in sRGB space, convert
back to linear (1 pow operation per pixel)

  ## Testing

- Verified that the UI gradient examples (`cargo run --example
gradients`) compile and render correctly
- The visual output should remain identical while performance improves,
especially for large gradient areas
- Changes maintain the same color interpolation behavior (mixing in sRGB
space)

  To test:
1. Run `cargo run --example gradients` or `cargo run --example
stacked_gradients`
  2. Verify gradients render correctly

---------

Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
2025-07-16 16:06:45 +00:00
Lenchog
8e14d99fb9
Added finish method for timer (#20154)
# Objective

- Add an easy way to finish a Timer

## Solution

- Tick the timer by the remaining time

## Testing

I have not tested, but it should work
---

## Showcase

```rust
let mut timer = Timer::from_seconds(1.5, TimerMode::Once);
timer.finish();
assert_eq!(timer.remaining(), Duration::from_secs(0))
```

---------

Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-07-15 22:57:57 +00:00
ickshonpe
d195116426
Improved UI scrolling support and bug fixes (#20093)
# Objective

#### Goals
* Stop layout updates from overwriting `ScrollPosition`.
* Make `ScrollPosition` respect scale factor.
* Automatically allocate space for a scrollbar on an axis when
`OverflowAxis::Scroll` is set.
 
#### Non-Goals
* Overflow-auto support (I was certain Taffy had this already, but
apparently I was hallucinating).
* Implement any sort of scrollbar widgets.
* Stability (not needed because no overflow-auto support).
* Maybe in the future we could make a `ScrollbarWidth` enum to more
closely match the CSS API with its auto/narrow/none options. For now
`scrollbar_width` is just an `f32` which matches Taffy's API.

## Solution

* Layout updates no longer overwrite `ScrollPosition`'s value.
* Added the field `scrollbar_width: f32` to `Node`. This is sent to
`Taffy` which will automatically allocate space for scrollbars with this
width in the layout as needed.
* Added the fields `scrollbar_width: f32` and `scroll_position: Vec2` to
`ComputedNode`. These are updated automatically during layout.
* `ScrollPosition` now respects scale factor.
* `ScrollPosition` is no longer automatically added to every UI node
entity by `ui_layout_system`. If every node needs it, it should just be
required by (or be a field on) `Node`. Not sure if that's necessary or
not.

## Testing
For testing you can look at:
* The `scrollbars` example, which should work as before.
* The new example `drag_to_scroll`.
* The `scroll` example which automatically allocates space for
scrollbars on the left hand scrolling list. Did not implement actual
scrollbars so you'll just see a gap atm.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-07-15 17:33:04 +00:00
ickshonpe
f774d6b7ed
Text2d bounding box fix (#20148)
# Objective

`calculate_bounds_text2d` generates `Aabb`s with the wrong size and
position for `Text2d` entities with `TextBounds`, which breaks culling.

## Solution

Calculate the correct bounds.

Fixes #20145

## Testing

```
cargo run --example testbed_2d
```

#### main
<img width="661" height="469" alt="text2daabb"
src="https://github.com/user-attachments/assets/c10b64ed-6e0d-4c4e-a81d-6ae2248d752a"
/>

#### This PR

<img width="441" height="308" alt="fixed-text2d-aabbs"
src="https://github.com/user-attachments/assets/bc715bf0-b77f-4149-9c6d-a5a8c1982780"
/>
2025-07-15 17:14:49 +00:00
Tim
57086d4416
Remove the need to derive Event when deriving EntityEvent (#20104)
# Objective
Since we are planning to remove the need to derive both `Event` and
`EntityEvent` in 0.17 either way, I'm choosing to do the easy thing in
this PR so we can get the churn out of the way early.

Context from
[discord](https://discordapp.com/channels/691052431525675048/1383928409784193024/1393463673137401946).
Related to, and will conflict slightly with #20101.

## Solution

- Derive `Event` as part of the `EntityEvent` derive
- Remove any `Event` derives that were made unnecessary
- Update release notes
2025-07-15 16:45:38 +00:00
andriyDev
2bddbdfd7c
Use RenderStartup for all basic cases in bevy_core_pipeline. (#20002)
# Objective

- Progress towards #19887.

## Solution

- Convert `FromWorld` impls into systems.
- Run those systems in `RenderStartup`.

## Testing

- Ran `bloom_3d`, `auto_exposure`, `depth_of_field`, `motion_blur`,
`skybox`, `post_processing`, and `tonemapping` examples and they all
work :)
2025-07-15 07:10:43 +00:00
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
andriyDev
2a5e9c1150
Switch most examples to use RenderStartup instead of finish and FromWorld. (#20124)
# Objective

- Progress towards #19887.
- I am avoiding dealing with the `occlusion_culling` example since it is
kinda annoying to resolve nicely (I will do so in another PR).

## Solution

- Rewrite these examples to replace FromWorld implementations with
systems and other resource changes with systems as well.

## Testing

- All the changed examples have been tested and still work.
2025-07-14 21:56:03 +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
Tim
ec6dd7e451
Refactor 2d_viewport_to_world example with let chains (#20090)
# Objective

Make use of let chains to reduce LoC where we previously used let else
to cut down on indentation. Best of both worlds.
Hmm, déjà vu?
2025-07-14 21:21:44 +00:00
Jan Hohenheim
36fb83fa42
Port the physics in fixed timestep example to 3D (#20089)
# Objective

Since I originally wrote this example, many people on Discord have asked
me specifically how to handle camera movement in and around fixed
timesteps. I had to write that information up maaaany times, so I
believe this is an area where the example falls short of.

## Solution

Let's port the example to 3D, where we can better showcase how to handle
the camera. The knowledge is trivially transferable to 2D :)
Also, we don't need to average out continuous input. Just using the last
one is fine in practice. Still, we need to keep around the
`AccumulatedInput` resource for things like jumping.

## Testing


https://github.com/user-attachments/assets/c1306d36-1f94-43b6-b8f6-af1cbb622698

## Notes

- The current implementation is extremely faithful to how it will look
like in practice when writing a 3D game using e.g. Avian. With the
exception that Avian does the part with the actual physics of course
- I'd love to showcase how to map sequences of inputs to fixed updates,
but winit does not export timestamps
- I'd also like to showcase instantaneous inputs like activating a boost
or shooting a laser, but that would make the example even bigger
- Not locking the cursor because doing so correctly on Wasm in the
current Bevy version is not trivial at all

---------

Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
2025-07-14 21:20:19 +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
liamaharon
0294fa89db
Mitigate Tracy dep version woes (#20109)
# Objective

Turns out, Tracy dep (in)compatibilities can be a headache. Here was my
experience following the [Profiling Tracy
documentation](1525dff7ad/docs/profiling.md (tracy-profiler)):

I ran into this error when I attempted to connect to my bevy client:

<img width="473" height="154" alt="Screenshot 2025-07-13 at 14 39 27"
src="https://github.com/user-attachments/assets/97634b37-253c-40ab-86ca-6eba02985638"
/>

Attempting to find where the version incompatibility stemmed, I found
these tracy dep versions and a link to the compatibility table in the
source:

1525dff7ad/crates/bevy_log/Cargo.toml (L32-L35)

This led me to believe I needed Tracy `0.11.1`, to match the
`tracy-client` version `0.18.0`.

This was confusing because `0.11.1` is the version I already had
installed (by running `brew install tracy`), and latest Tracy version
currently available on `brew`.

It turned out that Cargo was eagerly pulling `tracy-client` `0.18.2`
instead of `0.18.0`, making the Tracy version I needed actually
`0.12.2`. At the time of writing, `0.12.2` is not published on `brew`.

## Solution

I've pinned the Tracy deps, and mentioned in the comment which Tracy
version Bevy is compatible with.

I've also added some notes to [Profiling Tracy
documentation](1525dff7ad/docs/profiling.md (tracy-profiler))
to explain
- How to determine which Tracy version to install
- That MacOS users may need to compile from source if the required Tracy
version is not available on `brew`.

## Testing

- Did you test these changes? If so, how?
I ran Tracy locally.

- Are there any parts that need more testing?
I don't think so.

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

- If relevant, what platforms did you test these changes on, and are
there any important ones you can't test?
Tested MacOS. I think change should be OS agnostic.
2025-07-14 20:58:30 +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
atlv
1e057d8419
Add release note for light textures (#20023)
# Objective

- Fixes #19982

## Solution

- add note

## Testing

- left as an exercise for the reader
2025-07-14 20:47:45 +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
Tim
9ba643d7ba
Robust Scrolling Example (#19586)
# Objective

A more robust scrolling example that doesn't require `Pickable {
should_block_lower: false, .. }` or `Pickable::IGNORE`, and properly
handles nested scrolling nodes.

The current example shows nested scrolling, but this is only functional
because the parent scrolls along a different axis than the children.

## Solution

Instead of only scrolling the top node that is found in the `HoverMap`
we trigger the `OnScroll` event on it.
This event then propagates up the hierarchy until any scrolling node
that has room to scroll along that axis consumes the event.

The now redundant `Pickable` components were removed from the example.
The “Nested Scrolling Lists” portion was adjusted to show the new
reliable nested scrolling.

## Testing

Check out the example. It should work just as it did before.
2025-07-14 20:24:15 +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