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

Add AsyncSceneOutline #30

Closed
Shatur opened this issue Feb 18, 2024 · 5 comments
Closed

Add AsyncSceneOutline #30

Shatur opened this issue Feb 18, 2024 · 5 comments

Comments

@Shatur
Copy link
Contributor

Shatur commented Feb 18, 2024

bevy_xpbd have AsyncSceneCollider which initializes all colliders from meshes after scene loading.

It would be convenient to provide something like AsyncSceneOutline component and a system that listens for SceneInstanceReady event and for all entities with AsyncSceneOutline inserts InheritOutlineBundle to all their children.

@komadori
Copy link
Owner

Good idea, thanks. Added by 87df3aa.

@Shatur
Copy link
Contributor Author

Shatur commented Mar 12, 2024

@komadori Thanks! But I see that you use SceneSpawner. I think it's slover to iterate over all scenes. Instead you can just listen for SceneInstanceReady events.

@komadori
Copy link
Owner

komadori commented Mar 13, 2024

@Shatur My thinking at the time was what would happen if you added AsyncSceneInheritOutline after the scene had already loaded. I see now that a system that queried Added<AsyncSceneInheritOutline> could handle that in addition to listening for SceneInstanceReady, although I'm not sure if it's actually worth the bother.

More generally, I'm not entirely happy with the abstraction offered Bevy. Reading the discussion on bevyengine/bevy#9115, I'm not convinced that SceneInstanceReady wouldn't have been better as a marker component than as an event. While I'm not a bevy_ecs expert, I would think that the transient cost of an extra archetype while a scene is loading would be small compared to the cost of actually loading a scene and realising it. This would allow you efficiently query (With<AsyncSceneInheritOutline>, With<SceneInstanceReady>), whereas the event is produced for every scene even if it isn't marked.

Anyway, I'll have a see about changing it to use the event.

@Shatur
Copy link
Contributor Author

Shatur commented Mar 13, 2024

I suggested the marker component initially, but they decided on the event, so I edited the issue.
After using it for some time, I found it quite convenient.

@komadori
Copy link
Owner

Yes, I saw. Thanks for working on it. I think it will use some kind of per-entity event/observer pattern in the future once Bevy has support for it, and that will be the best solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants