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

Fix build with 'serde' feature + fix warning + update various dependencies #5

Closed
wants to merge 12 commits into from

Conversation

adrien-bon
Copy link

Hey!
Trying to add my little contribution to the porting effort.
If I have the time, I'll have a look into tiles and tilemaps removal after that.
Thanks for your amazing work! :)

@adrien-bon adrien-bon changed the title Fix build with 'serde' feature + tilemap changes detection Fix build with 'serde' feature + tilemap changes detection + fix render entities removal Nov 26, 2024
@adrien-bon
Copy link
Author

Added some logic to maintain a registry for mapping MainEntity to RenderEntity so we can properly remove entities in the render world.
Kind of naive implementation: there may be a more performant way to do that.

FYI, I'm testing with adrien-bon/bevy_ecs_tiled#45 (notably map_reload example)

@rparrett
Copy link
Owner

Thanks for the PR! I'll look at this closer when I get a chance. I'm not sure how much time I'll have over the holiday.

@rparrett
Copy link
Owner

rparrett commented Dec 3, 2024

Thanks again for sharing the work.

Working my way through these changes still. I pushed some stuff to my branch which might complicate things here in this PR.

I'd like to understand and be able to test the removal situation a bit better before proceeding there. Wondering if it makes sense to store the mapping on RenderChunkStorage2d and add some methods for removing by main-world entity. Maybe using MainEntity and MainEntityHashMap where applicable. But it may be best to just get something working in a minimal way and tidy up later.

I am mildly annoyed that we would have to maintain this sort of index, but I don't really see any way around it at the moment. I don't think we can get the RenderEntity from the main world while extracting the removals because it no longer exists at that point.

@rparrett
Copy link
Owner

rparrett commented Dec 3, 2024

Is it possible with observers or component hooks to retrieve the values of removed entities before they leave the world? Seems like it might be. Could potentially pass along the RenderEntity stored on the entity instead of the Entity. Bevy should already be inserting a RenderEntity on the tile in the main world.

@adrien-bon
Copy link
Author

Rebased the PR on your branch.

I agree with you, I don't like either keeping this RenderEntity / MainEntity mapping around (and I especially don't like how I construct it).
What I tried was to add a query in removal_helper_tilemap() and removal_helper() functions to get the RenderEntity and propagate it instead of the MainEntity. It did not work: the query never returned anything since I believe the underlying Entity was actually already removed at this point.
I'll give a try to components hooks instead, they are maybe called earlier, before the RenderEntity component is gone.

@rparrett
Copy link
Owner

rparrett commented Dec 3, 2024

I just pushed an obsever-based solution here: c06a01f

Which seems to work at a glance and feels really clean. I only tested by running the remove_tiles example so far though.

@adrien-bon
Copy link
Author

adrien-bon commented Dec 3, 2024

More removal than insertions, I like that.
I was doing the same kind of change but using hooks instead of observers, but I prefer your solution.

I believe we can drop this PR in favor of your branch.
Can you please also pick commits for fixing warning / compilation with serde feature ?

EDIT: commits list

EDIT 2: also updated the PR

@adrien-bon adrien-bon changed the title Fix build with 'serde' feature + tilemap changes detection + fix render entities removal Fix build with 'serde' feature + fix warning + update various dependencies Dec 3, 2024
@rparrett
Copy link
Owner

rparrett commented Dec 3, 2024

I'd prefer to leave the dependency updates for a followup unless there's something critical in there, or it's a duplicate due to a bump in Bevy.

@adrien-bon
Copy link
Author

Ok: fine for me! :)
Closing this PR, let's continue the discussion over StarArawn#574

@adrien-bon adrien-bon closed this Dec 3, 2024
@rparrett rparrett mentioned this pull request Dec 3, 2024
7 tasks
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

Successfully merging this pull request may close these issues.

2 participants