-
Notifications
You must be signed in to change notification settings - Fork 42
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 a Baseline Mapping to Preserve Relationships #74
Add a Baseline Mapping to Preserve Relationships #74
Conversation
This does add additional overhead, so it may be worth pursuing alternate strategies, perhaps through a PR to Bevy itself.
I was considering iterating over |
Agreed. I think it makes more sense to get a working but possibly slow solution now, instead of trying to get a partially correct but faster solution later. Premature optimization is the root of all evil, etc. |
Okay, I think we have the following options:
There are also rumors that Bevy will fundamentally change how they do relationships. Currently, I'm leaning towards 1, possibly with a way to opt out, and just wait to see what bevy comes up with. Curious to hear if @gschup has any thoughts on this. |
Had an idea for a possible horrible hack:
|
Interesting idea! I'll give that a try and see how it goes. |
Ok so I've pushed up an alteration to this PR which implements the concept @johanhelsing proposed. Instead of creating one large
It is possible to avoid using the It seems to work, but I'd like @johanhelsing to test it with a project that was previously broken to confirm it actually resolves the issue. Also, I don't know if it's faster than just making a big entity map at the beginning. I couldn't see an obvious problem in the |
On first glance, this seems like a good initial working solution. I wonder if there is a smarter way that avoids going through the map twice. In any case, we can figure optimizing this once it is no longer broken. |
As you were typing this I noticed that we can get a slight optimisation by just checking if the entity map grew after applying it the first time. If it didn't, then no dead entities were created, so a second mapping is not required. |
I'll give it a go. There might be other rollback issues in my game, though, bevy 0.10 -> 0.11 has been a tough one for me. Code looks sensible to me. I agree this is a good baseline. Should be correct, and adds relatively minimal (constant time) overhead. Not a bad deal to fix a serious regression. |
Seems to be working like a charm. No more broken parent-child relationships in my game 🎉 ...and particle effects work correctly in synctest sessions. My game is still a bit broken due to #71, I get a bunch of false positive (i think at least) desync errors so not a perfect test case yet. But still think it should be good to merge this once the conflicts are resolved 👍 |
Hmm... There is a quite noticeable performance drop in synctest sessions, though (in debug mode at least) |
lol. scratch that. I'm now pretty sure it was just my hierarchy sanity checking system that was running a lot more efficiently when hierarchies were actually broken |
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.
For now, I like the solution. The code in world_snapshot.rs is very monolithic, but that is something we can maybe approach once it works properly! Thanks for doing the work!
No problems! I look forward to helping out more on the future 😁 |
FWIW I found that parent->child transform propagation is still different/broken compared to before the bevy This does not work: .
└── parent
└── child1 <- follows parent just fine
└── child2 <- does not follow either parent unless with .add_rollback() This does work: .
└── parent
├── child1
└── child2 |
* Updates project to Bevy `0.11.3` and updates related dependencies. * Necessary fixes for breaking changes introduced by updates. * Switched to `bevy_ggrs` main branch to resolve a parent->child transform propagation regression ( See [here](gschup/bevy_ggrs#74) )
bevy_ggrs does not do anything to propagate transforms, i don't think it did before, and I'm not sure it should either... This pr was about the entity relations (what entity have what children) which I think should be ok now. |
@johanhelsing understood, just commenting as I found my original implementation broken by the Bevy 0.11 upgrade and thought it to be related. It is curious that using |
Gotcha. If you think something is still broken wrt hierarchies, it's probably best to open a new issue. |
Objective
Solution 1 (original)
Before populating the
EntityMap
used during rollback with tracked entities, all entities within theWorld
are added as no-op mappings:This does add additional overhead, so it may be worth pursuing alternate strategies, perhaps through a PR to Bevy itself.
Solution 2 (current; suggestion from @johanhelsing)
Reverse the mappings for any dead entities, and apply the map again:
This avoids the allocation of an
EntityMap
the size of all entities in theWorld
, but does require runningmap_all_entities
twice.