-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
set spawn_despawn on the correct entity when despawning #21364
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
set spawn_despawn on the correct entity when despawning #21364
Conversation
The test only does anything when track_location is on, which doesn't appear to be the case for the tests in the CI? a bit unfortunate. |
@janis-bhm can you incorporate the changes from #21359 into this PR please so we can merge it with passing tests? |
…nto ecs/fix-entity-spawn-despawn-on-despawn
# Objective Fixes #21293 Fixes #17314 to ensure that this is tested correctly. ## Solution when despawning an entity, previously the swapped in (archetype) or moved in entity (table) (which both require extra bookkeeping to update archetype or table rows) were marked as `spawned_or_despawned` by the location and tick that the to-be-removed entity was meant to be marked, while the to-be-removed entity wasn't marked. As pointed out by @akimakinai in [#19047](#19047), I've re-added the correct `mark_spawn_despawn` call to `despawn_with_caller`. ## Testing I've added a test `spawned_after_swap_remove` that ensures that despawning an entity by swapping doesn't effect other entities `spawned_or_despawned` location, and that it does effect the despawned entity's index's `spawned_or_despawned` location. Co-Authored By: waterwhisperer24@qq.com --------- Co-authored-by: WaterWhisperer <waterwhisperer24@qq.com>
world.flush(); | ||
|
||
// SAFETY: `self.entity` is a valid entity index | ||
unsafe { |
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.
I'm a little late here, but don't we still need to call mark_spawn_despawn()
before flush()
so that the value is updated before we run commands queued by any hooks?
...
Yeah, I just tested it, and it's possible to observe a stale value in a command, or to spawn a new entity that re-uses the index and have its spawed_by
overwritten. It's very much an edge case, but let me go make a quick PR to change that ... #21397.
…1364) # Objective Fixes bevyengine#21293 Fixes bevyengine#17314 to ensure that this is tested correctly. ## Solution when despawning an entity, previously the swapped in (archetype) or moved in entity (table) (which both require extra bookkeeping to update archetype or table rows) were marked as `spawned_or_despawned` by the location and tick that the to-be-removed entity was meant to be marked, while the to-be-removed entity wasn't marked. As pointed out by @akimakinai in [bevyengine#19047](bevyengine#19047), I've re-added the correct `mark_spawn_despawn` call to `despawn_with_caller`. ## Testing I've added a test `spawned_after_swap_remove` that ensures that despawning an entity by swapping doesn't effect other entities `spawned_or_despawned` location, and that it does effect the despawned entity's index's `spawned_or_despawned` location. Co-Authored By: waterwhisperer24@qq.com --------- Co-authored-by: WaterWhisperer <waterwhisperer24@qq.com>
Objective
Fixes #21293
Fixes #17314 to ensure that this is tested correctly.
Solution
when despawning an entity, previously the swapped in (archetype) or moved in entity (table) (which both require extra bookkeeping to update archetype or table rows) were marked as
spawned_or_despawned
by the location and tick that the to-be-removed entity was meant to be marked, while the to-be-removed entity wasn't marked.As pointed out by @akimakinai in #19047, I've re-added the correct
mark_spawn_despawn
call todespawn_with_caller
.Testing
I've added a test
spawned_after_swap_remove
that ensures that despawning an entity by swapping doesn't effect other entitiesspawned_or_despawned
location, and that it does effect the despawned entity's index'sspawned_or_despawned
location.Co-Authored By: waterwhisperer24@qq.com