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

Split Main world and Render world Entity space #14988

Closed
wants to merge 67 commits into from

Conversation

re0312
Copy link
Contributor

@re0312 re0312 commented Aug 30, 2024

Objective

  • Another way to get retain render world
  • Retain Rendering World #14449 proposes using an entity-to-entity mapping to avoid clearing all entities every frame in render world.However, it is confusing that main world entity may has a different entity ID to its corresponding entity in render world. It is foreseeable that it will significantly disrupt the existing rendering ecosystem and increase the maintenance burden on rendering personnel.

Solution

  • The idea of this PR is similar to subnet division ,it should allow people to divide the entity space into multiple worlds, and the world default entity allocation will only be in its own entity space, unless you call get_or_spawn to share entities across worlds.
  • In this PR, just simply allocate all even entity spaces to the main world and leave the rest to the rendering world.

Advantages

  1. Almost no burden to rendering people and break change is minimal.
  2. May open another door for assets as entities and networks
  3. No need to occupy any bit space in the Entity

Drawbacks

  1. Need to adjust the entity allocation method and the interface exposed to users.
  2. Extra memory usage , WorldCount * (20 * EntityCount + ( SparseSetComponentCount * 8 * SparseSetEntity) bytes, for example , after this PR, the memory of many_cubes (2 worlds ,16w Entities) increased from 380 mb to 390mb
  3. get(_mut) and SparseSet itertaion performance will decrease due to cache locality ( no more than 10%)

Performance

TODO


Migration Guide

TODO

@re0312 re0312 marked this pull request as draft August 30, 2024 19:21
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen A-ECS Entities, components, systems, and events X-Controversial There is active debate or serious implications around merging this PR S-Needs-SME Decision or review from an SME is required labels Aug 31, 2024
@bnyu
Copy link

bnyu commented Sep 3, 2024

Entity subspace, which looks like it may meets my needs.
I want my game main logic in lockstep to have deterministic, but others like UI or windows component entities are no need to have same in every player's games. I know this is not about render just say it, thank you for contributions.
So maybe it's better not to divide it with odd and even, maybe continuous blocks (may more cache-friendly), and there can be more defined block in the future?

@tychedelia
Copy link
Contributor

Can we close this?

@atlv24 atlv24 closed this Oct 3, 2024
@atlv24
Copy link
Contributor

atlv24 commented Oct 3, 2024

Closed as Retained render world has been merged #15320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events A-Rendering Drawing game state to the screen S-Needs-SME Decision or review from an SME is required X-Controversial There is active debate or serious implications around merging this PR
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants