Fix atmosphere not allowing multiple cameras#23113
Conversation
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
| @@ -797,7 +797,7 @@ pub(crate) fn write_atmosphere_buffer( | |||
| atmosphere_entity: Query<(&GpuAtmosphere, &GpuAtmosphereSettings), With<Camera3d>>, | |||
There was a problem hiding this comment.
We could probably make this a bit more idiomatic / nicer by swapping the Query here to Populated.
| mut atmosphere_buffer: ResMut<AtmosphereBuffer>, | ||
| ) { | ||
| let Ok((atmosphere, settings)) = atmosphere_entity.single() else { | ||
| let Some((atmosphere, settings)) = atmosphere_entity.iter().next() else { |
There was a problem hiding this comment.
This approach seems a bit weird: we're assuming that every camera uses the same atmosphere settings as the first camera that happens to match the camera?
There was a problem hiding this comment.
True, the AtmosphereBuffer is a resource, i am working on a commit to change it to a component
|
AtmosphereBuffer was changed from a Resource to a Component, and the pub function init_atmosphere_buffer was removed. These could be breaking changes |
|
Can be tested with this modified example |
|
It looks like your PR is a breaking change, but you didn't provide a migration guide. Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes. |
This makes sense to me, but it'll need a migration guide. The bot should be by with directions momentarily :) |
20cd993 to
ec07834
Compare
…here # Conflicts: # crates/bevy_pbr/src/render/mesh_view_bindings.rs
…here # Conflicts: # crates/bevy_pbr/src/render/mesh_view_bindings.rs
Objective
Allow multiple cameras to render an atmosphere enabling split screen and VR apps to use the feature
Solution
Use iter().next() instead of single() for when multiple Atmosphere entities exist
Testing
Tested this by adding a second camera to the atmosphere example.
Tested it in VR with the bevy_oxr crate