Add an API to clone worlds
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
> > I have a strong motivation to use shared entity ids for multiple worlds
>
> Can you explain this use case? What are you ultimately trying to achieve, and why is this strategy important to do this? The `EntityMapper` trait is designed for the serialization / networking use cases, and has been how Bevy serializes and deserializes scenes since Bevy 0.1 as far as I'm aware.
> ```Rust
>
> clone_entities(app.world(), app2.world_mut());
> reg.clone_world(app.world(), app2.world_mut());
> ```
> I simply want to clone worlds, the worlds should have identical IDs for multiple algorithm designs, and I want native performance. The serialized and deserialized scenes are too heavy. Generally, bevy relies on reflection to serialize and deserialize, which is an overkill solution. Serialization is not an option for cloning a world for high-performance applications.
>
> I have applications for power system simulation in Bevy. The ECS can become very successful in industrial applications that are not related to video games. Many algorithms such as Monte-Carlo simulation and N-1 stability verification require duplicating the data. In the design i have implemented, I only rely on the Clone trait to duplicate data. If the design permits, I will even choose to aggressively copy the archetype table as a whole and reconstruct the data in a new world.
>
_Originally posted by @chengts95 in [#15459](https://github.com/bevyengine/bevy/issues/15459#issuecomment-2508741620)_
Contributor guide
Assessment
This issue has not been assessed yet.