Skip to content

Commit 36668da

Browse files
authored
Merge branch 'main' into fix/image_target
2 parents 7797f28 + ae143d4 commit 36668da

File tree

126 files changed

+1804
-963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1804
-963
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ labels: C-Bug, S-Needs-Triage
66
assignees: ''
77
---
88

9-
## Bevy version
9+
## Bevy version and features
1010

11-
The release number or commit hash of the version you're using.
11+
- The release number or commit hash of the version you're using.
12+
- If you're not using default features, the combination of bevy's cargo features you are using.
1213

1314
## \[Optional\] Relevant system information
1415

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ jobs:
340340
steps:
341341
- uses: actions/checkout@v4
342342
- name: Check for typos
343-
uses: crate-ci/typos@v1.34.0
343+
uses: crate-ci/typos@v1.35.3
344344
- name: Typos info
345345
if: failure()
346346
run: |

assets/shaders/game_of_life.wgsl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
// Two textures are needed for the game of life as each pixel of step N depends on the state of its
55
// neighbors at step N-1.
66

7-
@group(0) @binding(0) var input: texture_storage_2d<r32float, read>;
7+
@group(0) @binding(0) var input: texture_storage_2d<rgba32float, read>;
88

9-
@group(0) @binding(1) var output: texture_storage_2d<r32float, write>;
9+
@group(0) @binding(1) var output: texture_storage_2d<rgba32float, write>;
10+
11+
@group(0) @binding(2) var<uniform> config: GameOfLifeUniforms;
12+
13+
struct GameOfLifeUniforms {
14+
alive_color: vec4<f32>,
15+
}
1016

1117
fn hash(value: u32) -> u32 {
1218
var state = value;
@@ -29,14 +35,15 @@ fn init(@builtin(global_invocation_id) invocation_id: vec3<u32>, @builtin(num_wo
2935

3036
let randomNumber = randomFloat((invocation_id.y << 16u) | invocation_id.x);
3137
let alive = randomNumber > 0.9;
32-
let color = vec4<f32>(f32(alive));
38+
// Use alpha channel to keep track of cell's state
39+
let color = vec4(config.alive_color.rgb, f32(alive));
3340

3441
textureStore(output, location, color);
3542
}
3643

3744
fn is_alive(location: vec2<i32>, offset_x: i32, offset_y: i32) -> i32 {
3845
let value: vec4<f32> = textureLoad(input, location + vec2<i32>(offset_x, offset_y));
39-
return i32(value.x);
46+
return i32(value.a);
4047
}
4148

4249
fn count_alive(location: vec2<i32>) -> i32 {
@@ -65,7 +72,7 @@ fn update(@builtin(global_invocation_id) invocation_id: vec3<u32>) {
6572
} else {
6673
alive = false;
6774
}
68-
let color = vec4<f32>(f32(alive));
75+
let color = vec4(config.alive_color.rgb, f32(alive));
6976

7077
textureStore(output, location, color);
7178
}

crates/bevy_animation/src/gltf_curves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<T> WideCubicKeyframeCurve<T> {
353353
let values: Vec<T> = values.into_iter().collect();
354354
let divisor = times.len() * 3;
355355

356-
if values.len() % divisor != 0 {
356+
if !values.len().is_multiple_of(divisor) {
357357
return Err(WideKeyframeCurveError::LengthMismatch {
358358
values_given: values.len(),
359359
divisor,

crates/bevy_animation/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ impl Plugin for AnimationPlugin {
12451245
// `PostUpdate`. For now, we just disable ambiguity testing
12461246
// for this system.
12471247
animate_targets
1248-
.before(bevy_mesh::InheritWeights)
1248+
.before(bevy_mesh::InheritWeightSystems)
12491249
.ambiguous_with_all(),
12501250
trigger_untargeted_animation_events,
12511251
expire_completed_transitions,

crates/bevy_anti_aliasing/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ keywords = ["bevy"]
1212
trace = []
1313
webgl = []
1414
webgpu = []
15-
smaa_luts = ["bevy_render/ktx2", "bevy_image/ktx2", "bevy_image/zstd"]
15+
smaa_luts = ["bevy_image/ktx2", "bevy_image/zstd"]
1616

1717
[dependencies]
1818
# bevy

crates/bevy_anti_aliasing/src/smaa/smaa.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ fn area(dist: vec2<f32>, e1: f32, e2: f32, offset: f32) -> vec2<f32> {
894894
tex_coord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;
895895

896896
// Do it!
897-
return textureSample(area_texture, edges_sampler, tex_coord).rg;
897+
return textureSampleLevel(area_texture, edges_sampler, tex_coord, 0.0).rg;
898898
}
899899

900900
//-----------------------------------------------------------------------------

crates/bevy_anti_aliasing/src/taa/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ fn prepare_taa_history_textures(
439439
texture_descriptor.label = Some("taa_history_2_texture");
440440
let history_2_texture = texture_cache.get(&render_device, texture_descriptor);
441441

442-
let textures = if frame_count.0 % 2 == 0 {
442+
let textures = if frame_count.0.is_multiple_of(2) {
443443
TemporalAntiAliasHistoryTextures {
444444
write: history_1_texture,
445445
read: history_2_texture,

crates/bevy_app/src/app.rs

Lines changed: 85 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,29 @@ impl App {
256256
/// plugins are ready, but can be useful for situations where you want to use [`App::update`].
257257
pub fn finish(&mut self) {
258258
// plugins installed to main should see all sub-apps
259-
let plugins = core::mem::take(&mut self.main_mut().plugin_registry);
260-
for plugin in &plugins {
261-
plugin.finish(self);
259+
// do hokey pokey with a boxed zst plugin (doesn't allocate)
260+
let mut hokeypokey: Box<dyn Plugin> = Box::new(HokeyPokey);
261+
for i in 0..self.main().plugin_registry.len() {
262+
core::mem::swap(&mut self.main_mut().plugin_registry[i], &mut hokeypokey);
263+
hokeypokey.finish(self);
264+
core::mem::swap(&mut self.main_mut().plugin_registry[i], &mut hokeypokey);
262265
}
263-
let main = self.main_mut();
264-
main.plugin_registry = plugins;
265-
main.plugins_state = PluginsState::Finished;
266+
self.main_mut().plugins_state = PluginsState::Finished;
266267
self.sub_apps.iter_mut().skip(1).for_each(SubApp::finish);
267268
}
268269

269270
/// Runs [`Plugin::cleanup`] for each plugin. This is usually called by the event loop after
270271
/// [`App::finish`], but can be useful for situations where you want to use [`App::update`].
271272
pub fn cleanup(&mut self) {
272273
// plugins installed to main should see all sub-apps
273-
let plugins = core::mem::take(&mut self.main_mut().plugin_registry);
274-
for plugin in &plugins {
275-
plugin.cleanup(self);
274+
// do hokey pokey with a boxed zst plugin (doesn't allocate)
275+
let mut hokeypokey: Box<dyn Plugin> = Box::new(HokeyPokey);
276+
for i in 0..self.main().plugin_registry.len() {
277+
core::mem::swap(&mut self.main_mut().plugin_registry[i], &mut hokeypokey);
278+
hokeypokey.cleanup(self);
279+
core::mem::swap(&mut self.main_mut().plugin_registry[i], &mut hokeypokey);
276280
}
277-
let main = self.main_mut();
278-
main.plugin_registry = plugins;
279-
main.plugins_state = PluginsState::Cleaned;
281+
self.main_mut().plugins_state = PluginsState::Cleaned;
280282
self.sub_apps.iter_mut().skip(1).for_each(SubApp::cleanup);
281283
}
282284

@@ -1390,6 +1392,12 @@ impl App {
13901392
}
13911393
}
13921394

1395+
// Used for doing hokey pokey in finish and cleanup
1396+
pub(crate) struct HokeyPokey;
1397+
impl Plugin for HokeyPokey {
1398+
fn build(&self, _: &mut App) {}
1399+
}
1400+
13931401
type RunnerFn = Box<dyn FnOnce(App) -> AppExit>;
13941402

13951403
fn run_once(mut app: App) -> AppExit {
@@ -1526,6 +1534,38 @@ mod tests {
15261534
}
15271535
}
15281536

1537+
struct PluginF;
1538+
1539+
impl Plugin for PluginF {
1540+
fn build(&self, _app: &mut App) {}
1541+
1542+
fn finish(&self, app: &mut App) {
1543+
// Ensure other plugins are available during finish
1544+
assert_eq!(
1545+
app.is_plugin_added::<PluginA>(),
1546+
!app.get_added_plugins::<PluginA>().is_empty(),
1547+
);
1548+
}
1549+
1550+
fn cleanup(&self, app: &mut App) {
1551+
// Ensure other plugins are available during finish
1552+
assert_eq!(
1553+
app.is_plugin_added::<PluginA>(),
1554+
!app.get_added_plugins::<PluginA>().is_empty(),
1555+
);
1556+
}
1557+
}
1558+
1559+
struct PluginG;
1560+
1561+
impl Plugin for PluginG {
1562+
fn build(&self, _app: &mut App) {}
1563+
1564+
fn finish(&self, app: &mut App) {
1565+
app.add_plugins(PluginB);
1566+
}
1567+
}
1568+
15291569
#[test]
15301570
fn can_add_two_plugins() {
15311571
App::new().add_plugins((PluginA, PluginB));
@@ -1595,6 +1635,39 @@ mod tests {
15951635
app.finish();
15961636
}
15971637

1638+
#[test]
1639+
fn test_get_added_plugins_works_during_finish_and_cleanup() {
1640+
let mut app = App::new();
1641+
app.add_plugins(PluginA);
1642+
app.add_plugins(PluginF);
1643+
app.finish();
1644+
}
1645+
1646+
#[test]
1647+
fn test_adding_plugin_works_during_finish() {
1648+
let mut app = App::new();
1649+
app.add_plugins(PluginA);
1650+
app.add_plugins(PluginG);
1651+
app.finish();
1652+
assert_eq!(
1653+
app.main().plugin_registry[0].name(),
1654+
"bevy_app::main_schedule::MainSchedulePlugin"
1655+
);
1656+
assert_eq!(
1657+
app.main().plugin_registry[1].name(),
1658+
"bevy_app::app::tests::PluginA"
1659+
);
1660+
assert_eq!(
1661+
app.main().plugin_registry[2].name(),
1662+
"bevy_app::app::tests::PluginG"
1663+
);
1664+
// PluginG adds PluginB during finish
1665+
assert_eq!(
1666+
app.main().plugin_registry[3].name(),
1667+
"bevy_app::app::tests::PluginB"
1668+
);
1669+
}
1670+
15981671
#[test]
15991672
fn test_derive_app_label() {
16001673
use super::AppLabel;

crates/bevy_app/src/sub_app.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -401,25 +401,29 @@ impl SubApp {
401401

402402
/// Runs [`Plugin::finish`] for each plugin.
403403
pub fn finish(&mut self) {
404-
let plugins = core::mem::take(&mut self.plugin_registry);
405-
self.run_as_app(|app| {
406-
for plugin in &plugins {
407-
plugin.finish(app);
408-
}
409-
});
410-
self.plugin_registry = plugins;
404+
// do hokey pokey with a boxed zst plugin (doesn't allocate)
405+
let mut hokeypokey: Box<dyn Plugin> = Box::new(crate::HokeyPokey);
406+
for i in 0..self.plugin_registry.len() {
407+
core::mem::swap(&mut self.plugin_registry[i], &mut hokeypokey);
408+
self.run_as_app(|app| {
409+
hokeypokey.finish(app);
410+
});
411+
core::mem::swap(&mut self.plugin_registry[i], &mut hokeypokey);
412+
}
411413
self.plugins_state = PluginsState::Finished;
412414
}
413415

414416
/// Runs [`Plugin::cleanup`] for each plugin.
415417
pub fn cleanup(&mut self) {
416-
let plugins = core::mem::take(&mut self.plugin_registry);
417-
self.run_as_app(|app| {
418-
for plugin in &plugins {
419-
plugin.cleanup(app);
420-
}
421-
});
422-
self.plugin_registry = plugins;
418+
// do hokey pokey with a boxed zst plugin (doesn't allocate)
419+
let mut hokeypokey: Box<dyn Plugin> = Box::new(crate::HokeyPokey);
420+
for i in 0..self.plugin_registry.len() {
421+
core::mem::swap(&mut self.plugin_registry[i], &mut hokeypokey);
422+
self.run_as_app(|app| {
423+
hokeypokey.cleanup(app);
424+
});
425+
core::mem::swap(&mut self.plugin_registry[i], &mut hokeypokey);
426+
}
423427
self.plugins_state = PluginsState::Cleaned;
424428
}
425429

0 commit comments

Comments
 (0)