Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationships (non-fragmenting, one-to-many) #17398

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f401fb3
Fragmenting Relations
cart Jan 10, 2025
961ea73
OnDespawn
cart Jan 11, 2025
dd999c7
Merge remote-tracking branch 'origin/main' into relations
cart Jan 14, 2025
c383baf
Minor fixes and clippy
cart Jan 14, 2025
1492844
Support deriving on_despawn and fix archetype flags
cart Jan 14, 2025
b4798f2
Derive relationship
cart Jan 14, 2025
44eb8b9
RelationshipSources derive
cart Jan 14, 2025
0bd10cd
Support arbitrary collections
cart Jan 14, 2025
c38bc9c
Add type constraint
cart Jan 14, 2025
0052080
Opt-in despawn_descendants. Apply commands on spawn
cart Jan 15, 2025
cf86a92
Better "private" error message
cart Jan 15, 2025
bdacea7
despawn_related
cart Jan 15, 2025
060a3fb
Reorganize relationship module
cart Jan 15, 2025
55864c0
Documentation and ci
cart Jan 16, 2025
f1988d9
Merge remote-tracking branch 'origin/main' into relations
cart Jan 16, 2025
a051983
Register on_despawn in World::bootstrap
cart Jan 16, 2025
e823d1c
Add commands access to RelatedSpawnerCommands
cart Jan 16, 2025
c69070d
Add comment about mutability to RelationshipSources
cart Jan 16, 2025
cae5020
More EntityWorldMut tests
cart Jan 16, 2025
7aab4af
Remove take()
cart Jan 16, 2025
0d6cffb
Add deprecated version of despawn_recursive
cart Jan 16, 2025
a6ebc65
Put the children first! Why won't anyone think of the children!
cart Jan 16, 2025
3cee622
Adding warning about infinite loops
cart Jan 16, 2025
b9efb1a
Warn about infinite loops
cart Jan 16, 2025
30723bc
Derive Relationship and RelationshipSources through Component
cart Jan 17, 2025
ac94d66
Add hierarchy docs and Deref impl
cart Jan 17, 2025
74eaf36
Update crates/bevy_ecs/src/relationship/mod.rs
cart Jan 17, 2025
6634492
Scary names not deprecation
cart Jan 17, 2025
ab00b6d
Clippy
cart Jan 17, 2025
3e84a87
RelationshipSources -> RelationshipTarget
cart Jan 17, 2025
966ebca
Fix doc link
cart Jan 17, 2025
ec626d6
Fix bug that occurs when inserting the same Parent on top of itself.
cart Jan 18, 2025
5851993
Fix test and clippy
cart Jan 18, 2025
874a310
taplo fmt
cart Jan 18, 2025
504b105
Clippy
cart Jan 18, 2025
626d35a
- ___ -
cart Jan 18, 2025
3799b57
Thank you miri <3
cart Jan 18, 2025
7865248
Feature gate bevy_reflect
cart Jan 18, 2025
da8874c
More optional reflection
cart Jan 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ criterion = { version = "0.5.1", features = ["html_reports"] }
# Bevy crates
bevy_app = { path = "../crates/bevy_app" }
bevy_ecs = { path = "../crates/bevy_ecs", features = ["multi_threaded"] }
bevy_hierarchy = { path = "../crates/bevy_hierarchy" }
bevy_math = { path = "../crates/bevy_math" }
bevy_picking = { path = "../crates/bevy_picking", features = [
"bevy_mesh_picking_backend",
Expand Down
5 changes: 2 additions & 3 deletions benches/benches/bevy_ecs/entity_cloning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use core::hint::black_box;
use benches::bench;
use bevy_ecs::bundle::Bundle;
use bevy_ecs::component::ComponentCloneHandler;
use bevy_ecs::hierarchy::Parent;
use bevy_ecs::reflect::AppTypeRegistry;
use bevy_ecs::{component::Component, world::World};
use bevy_hierarchy::{BuildChildren, CloneEntityHierarchyExt};
use bevy_math::Mat4;
use bevy_reflect::{GetTypeRegistration, Reflect};
use criterion::{criterion_group, Bencher, Criterion, Throughput};
Expand Down Expand Up @@ -142,8 +142,7 @@ fn bench_clone_hierarchy<B: Bundle + Default + GetTypeRegistration>(

for parent_id in current_hierarchy_level {
for _ in 0..children {
let child_id = world.spawn(B::default()).set_parent(parent_id).id();

let child_id = world.spawn((B::default(), Parent(parent_id))).id();
cart marked this conversation as resolved.
Show resolved Hide resolved
hierarchy_level.push(child_id);
}
}
Expand Down
6 changes: 1 addition & 5 deletions benches/benches/bevy_ecs/observers/propagation.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use core::hint::black_box;

use bevy_ecs::{
component::Component, entity::Entity, event::Event, observer::Trigger, world::World,
};
use bevy_hierarchy::{BuildChildren, Parent};

use bevy_ecs::prelude::*;
use criterion::Criterion;
use rand::SeedableRng;
use rand::{seq::IteratorRandom, Rng};
Expand Down
5 changes: 1 addition & 4 deletions benches/benches/bevy_ecs/world/despawn_recursive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use bevy_ecs::prelude::*;
use bevy_hierarchy::despawn_with_children_recursive;
use bevy_hierarchy::BuildChildren;
use bevy_hierarchy::ChildBuild;
use criterion::Criterion;
use glam::*;

Expand Down Expand Up @@ -29,7 +26,7 @@ pub fn world_despawn_recursive(criterion: &mut Criterion) {
group.bench_function(format!("{}_entities", entity_count), |bencher| {
bencher.iter(|| {
ents.iter().for_each(|e| {
despawn_with_children_recursive(&mut world, *e, true);
world.entity_mut(*e).despawn();
});
});
});
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_animation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ bevy_time = { path = "../bevy_time", version = "0.16.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.16.0-dev" }
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.16.0-dev" }

# other
petgraph = { version = "0.6", features = ["serde-1"] }
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ impl Default for App {
{
app.init_resource::<AppTypeRegistry>();
app.register_type::<Name>();
app.register_type::<Parent>();
app.register_type::<Children>();
}

#[cfg(feature = "reflect_functions")]
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ keywords = ["bevy"]
bevy_app = { path = "../bevy_app", version = "0.16.0-dev" }
bevy_asset = { path = "../bevy_asset", version = "0.16.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.16.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.16.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", features = [
"bevy",
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_audio/src/audio_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
};
use bevy_asset::{Asset, Assets};
use bevy_ecs::{prelude::*, system::SystemParam};
use bevy_hierarchy::DespawnRecursiveExt;
use bevy_math::Vec3;
use bevy_transform::prelude::GlobalTransform;
use rodio::{OutputStream, OutputStreamHandle, Sink, Source, SpatialSink};
Expand Down Expand Up @@ -253,12 +252,12 @@ pub(crate) fn cleanup_finished_audio<T: Decodable + Asset>(
) {
for (entity, sink) in &query_nonspatial_despawn {
if sink.sink.empty() {
commands.entity(entity).despawn_recursive();
commands.entity(entity).despawn();
}
}
for (entity, sink) in &query_spatial_despawn {
if sink.sink.empty() {
commands.entity(entity).despawn_recursive();
commands.entity(entity).despawn();
}
}
for (entity, sink) in &query_nonspatial_remove {
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_dev_tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ bevy_asset = { path = "../bevy_asset", version = "0.16.0-dev" }
bevy_color = { path = "../bevy_color", version = "0.16.0-dev" }
bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.16.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.16.0-dev" }
bevy_input = { path = "../bevy_input", version = "0.16.0-dev" }
bevy_picking = { path = "../bevy_picking", version = "0.16.0-dev" }
bevy_render = { path = "../bevy_render", version = "0.16.0-dev" }
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_dev_tools/src/fps_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use bevy_ecs::{
schedule::{common_conditions::resource_changed, IntoSystemConfigs},
system::{Commands, Query, Res, Resource},
};
use bevy_hierarchy::{BuildChildren, ChildBuild};
use bevy_render::view::Visibility;
use bevy_text::{Font, TextColor, TextFont, TextSpan};
use bevy_ui::{
Expand Down
Loading
Loading