Test for orphan parent-child relations#1278
Test for orphan parent-child relations#1278TheRawMeatball wants to merge 1 commit intobevyengine:mainfrom
Conversation
|
(Apologies to @cart if this functionality already exists and we somehow missed it buried somewhere.) At a high-level this shares a lot of the same challenges as indexes (#1205): you have more than one delocalized copy of the data. However, because entities and components can only be removed at sync points (between stages), our freshness concerns are much lower. We can carefully control mutation via a limited API, so our only concern here is how to make sure orphaned components are also removed. Linear search solutionThe naive solution here would be to add a system that runs at the end of each stage. Scan through every copy of We can speed this up a little bit by keeping a list of the entities that have had their component removed, but this is still linear time. This works, but has bad complexity due to wasted work. Cached solutionI think we could use This requires us to update a cached copy of the component every time it's changed though, which seems like it may be frustrating and slow. Index solutionIf we had a working index solution, we could use it to cull the orphan relations by grabbing the list of entities with This requires #1205 to be resolved though. Notes
|
|
This problem will hopefully be solved eventually with the addition of relations (#1627), so this PR can be closed until then :) |
Currently, using
Commands::despawn()leads to orphaned parent-child relations. These should be automatically cleaned up, so this PR adds a test case against such orphan relations.