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

Ignore ambiguous components or resources #9895

Merged
merged 14 commits into from
Oct 4, 2023

Conversation

hymm
Copy link
Contributor

@hymm hymm commented Sep 22, 2023

Objective

Solution

  • Add a IgnoreSchedulingAmbiguitiy resource to the world which holds the ComponentIds to be ignored
  • Filter out ambiguities with those component id's.

Changelog

  • add allow_ambiguous_component and allow_ambiguous_resource apis for ignoring ambiguities

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Sep 22, 2023
@alice-i-cecile
Copy link
Member

@rj00a can I get your review on this as a user please?

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use this internally in this PR for some of our asset collection ambiguities.

@hymm
Copy link
Contributor Author

hymm commented Sep 22, 2023

@alice-i-cecile I added exceptions for Assets<Image> and Assets<TextureAtlas>, but do you think we should do this for all Assets<T>?

@@ -1710,6 +1732,22 @@ impl ScheduleBuildSettings {
}
}

/// list of [`ComponentId`]'s to ignore when reporting ambiguity conflicts between systems
#[derive(Resource, Default, Clone)]
pub struct IgnoreSchedulingAmbiguities(Vec<ComponentId>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have two distinct fields: one for resources, and one for components. Otherwise the API below doesn't make sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference between one or two fields can't be observed in the API, so this seems alright to me. Only reason I could think to split it would be for a nicer Debug impl.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of splitting it up, makes the logic for filtering more complicated.

@alice-i-cecile
Copy link
Member

@alice-i-cecile I added exceptions for Assets<Image> and Assets<TextureAtlas>, but do you think we should do this for all Assets<T>?

I think so: @cart's opinion was that basically all of these ambiguities are noise. Probably include it in the docs for asset registration too?

@hymm hymm force-pushed the ambiguous-components branch from 24e1525 to d5f0864 Compare September 22, 2023 05:12
Copy link
Contributor

@rj00a rj00a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks good to me.

crates/bevy_app/src/app.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/schedule/schedule.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/schedule/schedule.rs Outdated Show resolved Hide resolved
@hymm hymm force-pushed the ambiguous-components branch from 14a6808 to 3d407c5 Compare September 26, 2023 16:39
@@ -261,6 +261,9 @@ pub trait AssetApp {
/// * Registering the [`Asset`] in the [`AssetServer`]
/// * Initializing the [`AssetEvent`] resource for the [`Asset`]
/// * Adding other relevant systems and resources for the [`Asset`]
/// * Ignoring schedule ambiguities in [`Assets`] resource. Any time a system takes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: a unit test to validate that these docs stay correct would be nice.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Sep 28, 2023
Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I like the idea of using a resource for this purpose. It seems trivial to alter behavior at runtime by mutating or removing the resource. IMO this should be a part of the World itself instead of included as an item we store in it.

@alice-i-cecile alice-i-cecile added this to the 0.12 milestone Oct 2, 2023
@alice-i-cecile
Copy link
Member

We already store Schedules as a resource to be fair. I'd rather make this a field of that than move it up to the World level.

@hymm
Copy link
Contributor Author

hymm commented Oct 3, 2023

I actually started with it as part of Schedules and moved it to a separate resource since it's felt like more a property of the world to be ambiguous on a component. I'm fine with moving it back into Schedules if that seems more appropriate or even making it a part of World. I don't have a strong opinion on this one.

@alice-i-cecile
Copy link
Member

I think that this is tightly coupled to the scheduling information: long-term, I think that all of our cross-schedule config belongs under Schedules. Move it there and then I think we can merge.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 4, 2023
Merged via the queue into bevyengine:main with commit 7c5b324 Oct 4, 2023
21 checks passed
@hymm hymm deleted the ambiguous-components branch October 5, 2023 16:12
@cart cart mentioned this pull request Oct 13, 2023
43 tasks
regnarock pushed a commit to regnarock/bevy that referenced this pull request Oct 13, 2023
# Objective

- Fixes bevyengine#9884
- Add API for ignoring ambiguities on certain resource or components.

## Solution

- Add a `IgnoreSchedulingAmbiguitiy` resource to the world which holds
the `ComponentIds` to be ignored
- Filter out ambiguities with those component id's.

## Changelog

- add `allow_ambiguous_component` and `allow_ambiguous_resource` apis
for ignoring ambiguities

---------

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective

- Fixes bevyengine#9884
- Add API for ignoring ambiguities on certain resource or components.

## Solution

- Add a `IgnoreSchedulingAmbiguitiy` resource to the world which holds
the `ComponentIds` to be ignored
- Filter out ambiguities with those component id's.

## Changelog

- add `allow_ambiguous_component` and `allow_ambiguous_resource` apis
for ignoring ambiguities

---------

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- Fixes bevyengine#9884
- Add API for ignoring ambiguities on certain resource or components.

## Solution

- Add a `IgnoreSchedulingAmbiguitiy` resource to the world which holds
the `ComponentIds` to be ignored
- Filter out ambiguities with those component id's.

## Changelog

- add `allow_ambiguous_component` and `allow_ambiguous_resource` apis
for ignoring ambiguities

---------

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ignore system order ambiguities from specific components and resources.
4 participants