-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fix removal of script contexts #81
Conversation
I just added some changes to the context_entities. bevy_mod_scripting/bevy_mod_scripting_core/src/hosts.rs Lines 267 to 271 in 9cf9e7f
I would love to hear some feedback from you, I personally think it makes more sense to use the entity as a key, instead of the script ID. I'll now work on fixing the tests, and the other CI issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I see the benefits of keeping entities as the keys in change detection, it adds load to the hot path, i.e. iterating through all the scripts on top of decreasing cache locality with a nested Vec.
I'd much rather have to iterate through all the contexts to find the right scripts to remove than have to do some additional work when handling events :)
I see, haven't considered that! |
Merge Request is back at only fixing the bug in removing script context |
No worries, much appreciated! Just one code style comment and I am happy! |
Co-authored-by: Maksymilian Mozolewski <[email protected]>
This should fix #79.
Okay i found following issue:
the system
script_remove_synchronizer
handles removing the contexts of the script.bevy_mod_scripting/bevy_mod_scripting_core/src/systems.rs
Lines 94 to 103 in 32eba12
The problem here is, that
.remove_context
expects the script ID, ascontext_entities
uses it as the Key.bevy_mod_scripting/bevy_mod_scripting_core/src/hosts.rs
Lines 267 to 271 in 32eba12
Which results in a very unreliable removing of the scripts. especially once the entities have multiple scripts and not just one.
I have updated the
script_remove_synchronizer
system, to loop through allcontext_entities
and find those with a matching entity id.The problem I see with this solution is that we have to loop through everything, as we can't break after one found match. because each entity could have multiple scripts, so we need to loop through all of them to find all.
bevy_mod_scripting/bevy_mod_scripting_core/src/systems.rs
Lines 94 to 112 in 745c20b