Skip to content

Commit a5d631b

Browse files
authored
Merge branch 'main' into render-target-component
2 parents aa6aafd + 3953ce0 commit a5d631b

File tree

172 files changed

+4970
-3382
lines changed

Some content is hidden

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

172 files changed

+4970
-3382
lines changed

.github/workflows/action-on-PR-labeled.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
env:
3131
BASE_SHA: ${{ github.event.pull_request.base.sha }}
3232
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
33-
- uses: actions/github-script@v7
33+
- uses: actions/github-script@v8
3434
if: steps.get_changes.outputs.found_changes == '0'
3535
with:
3636
script: |
@@ -60,7 +60,7 @@ jobs:
6060
env:
6161
BASE_SHA: ${{ github.event.pull_request.base.sha }}
6262
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
63-
- uses: actions/github-script@v7
63+
- uses: actions/github-script@v8
6464
if: steps.get_changes.outputs.found_changes == '0'
6565
with:
6666
script: |

.github/workflows/ci-comment-failures.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
steps:
2424
- name: 'Download artifact'
2525
id: find-artifact
26-
uses: actions/github-script@v7
26+
uses: actions/github-script@v8
2727
with:
2828
result-encoding: string
2929
script: |
@@ -63,7 +63,7 @@ jobs:
6363
fi
6464
- name: "Comment on PR"
6565
if: ${{ steps.find-artifact.outputs.result == 'true' && steps.check-last-comment.outputs.result == 'false' }}
66-
uses: actions/github-script@v7
66+
uses: actions/github-script@v8
6767
with:
6868
github-token: ${{ secrets.GITHUB_TOKEN }}
6969
script: |
@@ -94,7 +94,7 @@ jobs:
9494
steps:
9595
- name: 'Download artifact'
9696
id: find-artifact
97-
uses: actions/github-script@v7
97+
uses: actions/github-script@v8
9898
with:
9999
result-encoding: string
100100
script: |
@@ -134,7 +134,7 @@ jobs:
134134
fi
135135
- name: "Comment on PR"
136136
if: ${{ steps.find-artifact.outputs.result == 'true' && steps.check-last-comment.outputs.result == 'false' }}
137-
uses: actions/github-script@v7
137+
uses: actions/github-script@v8
138138
with:
139139
github-token: ${{ secrets.GITHUB_TOKEN }}
140140
script: |
@@ -165,7 +165,7 @@ jobs:
165165
steps:
166166
- name: 'Download artifact'
167167
id: find-artifact
168-
uses: actions/github-script@v7
168+
uses: actions/github-script@v8
169169
with:
170170
result-encoding: string
171171
script: |
@@ -205,7 +205,7 @@ jobs:
205205
fi
206206
- name: "Comment on PR"
207207
if: ${{ steps.find-artifact.outputs.result == 'true' && steps.check-last-comment.outputs.result == 'false' }}
208-
uses: actions/github-script@v7
208+
uses: actions/github-script@v8
209209
with:
210210
github-token: ${{ secrets.GITHUB_TOKEN }}
211211
script: |

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ jobs:
305305
# Full git history is needed to get a proper list of changed files within `super-linter`
306306
fetch-depth: 0
307307
- name: Run Markdown Lint
308-
uses: super-linter/super-linter/slim@v8.0.0
308+
uses: super-linter/super-linter/slim@v8.1.0
309309
env:
310310
MULTI_STATUS: false
311311
VALIDATE_ALL_CODEBASE: false

.github/workflows/example-run-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
steps:
2626
- name: "Download artifact"
2727
id: find-artifact
28-
uses: actions/github-script@v7
28+
uses: actions/github-script@v8
2929
with:
3030
result-encoding: string
3131
script: |

.github/workflows/welcome.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
permissions:
1515
pull-requests: write
1616
steps:
17-
- uses: actions/github-script@v7
17+
- uses: actions/github-script@v8
1818
with:
1919
script: |
2020
// Get a list of all issues created by the PR opener

Cargo.toml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,14 @@ serde = { version = "1", features = ["derive"] }
602602
serde_json = "1.0.140"
603603
bytemuck = "1"
604604
# The following explicit dependencies are needed for proc macros to work inside of examples as they are part of the bevy crate itself.
605-
bevy_render = { path = "crates/bevy_render", version = "0.17.0-dev", default-features = false }
606-
bevy_ecs = { path = "crates/bevy_ecs", version = "0.17.0-dev", default-features = false }
607-
bevy_state = { path = "crates/bevy_state", version = "0.17.0-dev", default-features = false }
605+
bevy_animation = { path = "crates/bevy_animation", version = "0.17.0-dev", default-features = false }
608606
bevy_asset = { path = "crates/bevy_asset", version = "0.17.0-dev", default-features = false }
609-
bevy_reflect = { path = "crates/bevy_reflect", version = "0.17.0-dev", default-features = false }
610-
bevy_image = { path = "crates/bevy_image", version = "0.17.0-dev", default-features = false }
607+
bevy_ecs = { path = "crates/bevy_ecs", version = "0.17.0-dev", default-features = false }
611608
bevy_gizmos = { path = "crates/bevy_gizmos", version = "0.17.0-dev", default-features = false }
609+
bevy_image = { path = "crates/bevy_image", version = "0.17.0-dev", default-features = false }
610+
bevy_reflect = { path = "crates/bevy_reflect", version = "0.17.0-dev", default-features = false }
611+
bevy_render = { path = "crates/bevy_render", version = "0.17.0-dev", default-features = false }
612+
bevy_state = { path = "crates/bevy_state", version = "0.17.0-dev", default-features = false }
612613
# Needed to poll Task examples
613614
futures-lite = "2.0.1"
614615
futures-timer = { version = "3", features = ["wasm-bindgen", "gloo-timers"] }
@@ -2719,6 +2720,17 @@ description = "Demonstrates how reflection in Bevy provides a way to dynamically
27192720
category = "Reflection"
27202721
wasm = false
27212722

2723+
[[example]]
2724+
name = "serialization"
2725+
path = "examples/reflection/serialization.rs"
2726+
doc-scrape-examples = true
2727+
2728+
[package.metadata.example.serialization]
2729+
name = "Serialization"
2730+
description = "Demonstrates serialization and deserialization using reflection without serde's Serialize/Deserialize traits"
2731+
category = "Reflection"
2732+
wasm = false
2733+
27222734
[[example]]
27232735
name = "custom_attributes"
27242736
path = "examples/reflection/custom_attributes.rs"
@@ -3877,6 +3889,15 @@ doc-scrape-examples = true
38773889
[package.metadata.example.minimizing]
38783890
hidden = true
38793891

3892+
[[example]]
3893+
name = "desktop_request_redraw"
3894+
path = "tests/window/desktop_request_redraw.rs"
3895+
doc-scrape-examples = true
3896+
required-features = ["bevy_dev_tools"]
3897+
3898+
[package.metadata.example.desktop_request_redraw]
3899+
hidden = true
3900+
38803901
[[example]]
38813902
name = "window_resizing"
38823903
path = "examples/window/window_resizing.rs"
Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use core::hint::black_box;
22

33
use bevy_ecs::{
4-
event::EntityEvent,
5-
observer::{On, TriggerTargets},
4+
entity::Entity,
5+
event::{EntityEvent, Event},
6+
observer::On,
67
world::World,
78
};
89

@@ -13,43 +14,50 @@ fn deterministic_rand() -> ChaCha8Rng {
1314
ChaCha8Rng::seed_from_u64(42)
1415
}
1516

16-
#[derive(Clone, EntityEvent)]
17-
struct EventBase;
17+
#[derive(Clone, Event)]
18+
struct A;
1819

19-
pub fn observe_simple(criterion: &mut Criterion) {
20+
pub fn observer_custom(criterion: &mut Criterion) {
2021
let mut group = criterion.benchmark_group("observe");
2122
group.warm_up_time(core::time::Duration::from_millis(500));
2223
group.measurement_time(core::time::Duration::from_secs(4));
2324

24-
group.bench_function("trigger_simple", |bencher| {
25+
group.bench_function("observer_custom", |bencher| {
2526
let mut world = World::new();
26-
world.add_observer(empty_listener_base);
27+
world.add_observer(on_a);
2728
bencher.iter(|| {
2829
for _ in 0..10000 {
29-
world.trigger(EventBase);
30+
world.trigger(A);
3031
}
3132
});
3233
});
3334

34-
group.bench_function("trigger_targets_simple/10000_entity", |bencher| {
35+
group.bench_function("observer_custom/10000_entity", |bencher| {
3536
let mut world = World::new();
3637
let mut entities = vec![];
3738
for _ in 0..10000 {
38-
entities.push(world.spawn_empty().observe(empty_listener_base).id());
39+
entities.push(world.spawn_empty().observe(on_b).id());
3940
}
4041
entities.shuffle(&mut deterministic_rand());
4142
bencher.iter(|| {
42-
send_base_event(&mut world, &entities);
43+
for entity in entities.iter().copied() {
44+
world.trigger(B { entity });
45+
}
4346
});
4447
});
4548

4649
group.finish();
4750
}
4851

49-
fn empty_listener_base(event: On<EventBase>) {
52+
fn on_a(event: On<A>) {
5053
black_box(event);
5154
}
5255

53-
fn send_base_event(world: &mut World, entities: impl TriggerTargets) {
54-
world.trigger_targets(EventBase, entities);
56+
#[derive(Clone, EntityEvent)]
57+
struct B {
58+
entity: Entity,
59+
}
60+
61+
fn on_b(event: On<B>) {
62+
black_box(event);
5563
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use bevy_ecs::{component::Component, lifecycle::Insert, observer::On, world::World};
2+
use core::hint::black_box;
3+
use criterion::Criterion;
4+
use rand::SeedableRng;
5+
use rand_chacha::ChaCha8Rng;
6+
7+
fn deterministic_rand() -> ChaCha8Rng {
8+
ChaCha8Rng::seed_from_u64(42)
9+
}
10+
11+
pub fn observer_lifecycle(criterion: &mut Criterion) {
12+
let mut group = criterion.benchmark_group("observe");
13+
group.warm_up_time(core::time::Duration::from_millis(500));
14+
group.measurement_time(core::time::Duration::from_secs(4));
15+
16+
group.bench_function("observer_lifecycle_insert", |bencher| {
17+
let mut world = World::new();
18+
world.add_observer(on_insert);
19+
let mut entity = world.spawn(A);
20+
bencher.iter(|| {
21+
for _ in 0..10000 {
22+
entity.insert(A);
23+
}
24+
});
25+
});
26+
27+
group.finish();
28+
}
29+
30+
#[derive(Component)]
31+
struct A;
32+
33+
fn on_insert(event: On<Insert, A>) {
34+
black_box(event);
35+
}
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
mod custom;
2+
mod lifecycle;
13
mod propagation;
2-
mod simple;
34

45
use criterion::criterion_group;
6+
use custom::*;
7+
use lifecycle::*;
58
use propagation::*;
6-
use simple::*;
79

8-
criterion_group!(benches, event_propagation, observe_simple);
10+
criterion_group!(
11+
benches,
12+
event_propagation,
13+
observer_custom,
14+
observer_lifecycle
15+
);

benches/benches/bevy_ecs/observers/propagation.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ pub fn event_propagation(criterion: &mut Criterion) {
6262
}
6363

6464
#[derive(EntityEvent, Clone, Component)]
65-
#[entity_event(traversal = &'static ChildOf, auto_propagate)]
66-
struct TestEvent<const N: usize> {}
65+
#[entity_event(propagate, auto_propagate)]
66+
struct TestEvent<const N: usize> {
67+
entity: Entity,
68+
}
6769

6870
fn send_events<const N: usize, const N_EVENTS: usize>(world: &mut World, leaves: &[Entity]) {
69-
let target = leaves.iter().choose(&mut rand::rng()).unwrap();
71+
let entity = *leaves.iter().choose(&mut rand::rng()).unwrap();
7072

7173
(0..N_EVENTS).for_each(|_| {
72-
world.trigger_targets(TestEvent::<N> {}, *target);
74+
world.trigger(TestEvent::<N> { entity });
7375
});
7476
}
7577

0 commit comments

Comments
 (0)