bevyengine / bevyengine/bevy

Efficient World merging

Open
#12,545 4 comments 1 reaction 0 assignees View on GitHub
A-ECS A-Scenes C-Feature C-Performance D-Complex
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?
Minimize the time spent in the critical section in mutating the `World` when loading scenes.

## What solution would you like?
A `World::merge_with(&mut World)` API that moves all of the entities, components, and resources from the provided world into the world it's being called on. The source world will be empty once complete.

This should support scene loads in a consumptive way. Assuming the scene doesn't need to exist after merging with the world (i.e. an environmental load, not a prefab-like spawn of multiple characters or bullets), this should minimize the need for reflection in the critical path.

This should be safe to do, though any systems in the system registry will likely fail to run once merged into the new world due to a WorldId mismatch. Likewise any metadata-as-entities (i.e. Components as entities) will likely need to be guarded against as well to invalidating the internal state of either world.

## What alternative(s) have you considered?
Continue using our current reflection based approach.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing reflection-based scene-loading path and the World::merge_with API described in the issue. Review the system registry and metadata-as-entities constraints before choosing an approach. Done means the destination owns all entities, components, and resources, the source world is empty, and WorldId or metadata state remains safe.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.