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

Handle Tiled worlds #63

Merged
merged 25 commits into from
Jan 6, 2025
Merged

Handle Tiled worlds #63

merged 25 commits into from
Jan 6, 2025

Conversation

adrien-bon
Copy link
Owner

Closes #55

@adrien-bon
Copy link
Owner Author

adrien-bon commented Dec 14, 2024

Nothing fancy yet, just moved around files so we can have everything related to Tiled worlds in a dedicated module.

@JtotheThree: please use this branch as destination if you want to open a PR
(no hurry though! :))

@adrien-bon adrien-bon linked an issue Dec 14, 2024 that may be closed by this pull request
@adrien-bon
Copy link
Owner Author

adrien-bon commented Dec 27, 2024

Next things to do:

  • Wait for official rs-tiled release with world support. PR = World File Parsing mapeditor/rs-tiled#320
  • Analyze initial loading performances and find a way to improve them if needed, We want to be able to load at least "medium sized" maps without any stutter (like 32x32 tiles)
  • Double-check chunking code: it feels like we may have a situation where we spawn / despawn maps every frames if we have several Cameras:
  • Seems like tiled::World field source is always empty. Posted a comment in rs-tiled PR.
  • Find a way to pass along PhysicsSettings<T> from the world entity to the maps: we want the map to inherit the settings from their parent world
  • Check what happens if we have a world with infinite maps. Eventhough it does not make a lot of sense, I'm affraid we may currently have a crash if we do so (map.widht().unwrap() in world/asset.rs). We may just throw an error instead
  • Would be cool to have some sort of debug visualization of the chunking area (like a gizmo ?). Obviously, not very high in the prioty list :)
  • Make sure we have proper documentation for the new types and add a dedicated section in the book regarding usage of worlds
  • Test Tiled user_properties with worlds. Add a mechanism (with a marker component ?) to keep around some objects from a map when it is despawned then restore them when the map is spawned again.

@adrien-bon
Copy link
Owner Author

Just tested to spawn physics colliders with our test world: it's very laggy.
That's probably because we have one collider per tile.
We'll probably need to optimize that and find a solution to "merge" colliders together.

@adrien-bon adrien-bon changed the title Feat/world Handle Tiled worlds Dec 29, 2024
@adrien-bon
Copy link
Owner Author

Encountered what seems to be a randome crash:

2024-12-29T17:42:28.568937Z  INFO bevy_ecs_tiled::map::asset: Loaded map 'world/world_map025.tmx'    
2024-12-29T17:42:28.711035Z  INFO bevy_ecs_tiled::world: World 'world/world.world' has finished loading, spawn it
2024-12-29T17:42:28.711126Z  INFO bevy_ecs_tiled::map: Map 'world/world_map021.tmx' has finished loading, spawn it
thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.15.0/src/system/commands/mod.rs:1982:13:
error[B0003]: src/map/loader.rs:53:33: Could not insert a bundle (of type `(bevy_core::name::Name, bevy_ecs_tiled::map::components::TiledMapMarker)`) for entity 13v1#4294967309 because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic when applying buffers for system `bevy_ecs_tiled::map::process_loaded_maps`!
2024-12-29T17:42:28.712193Z  WARN bevy_ecs::world::command_queue: CommandQueue has un-applied commands being dropped. Did you forget to call SystemState::apply?
2024-12-29T17:42:28.712299Z  WARN bevy_ecs::world::command_queue: CommandQueue has un-applied commands being dropped. Did you forget to call SystemState::apply?
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

@adrien-bon adrien-bon marked this pull request as ready for review January 6, 2025 19:33
@adrien-bon adrien-bon merged commit 6324e40 into dev Jan 6, 2025
5 checks passed
@adrien-bon
Copy link
Owner Author

Remaining items on the checklist will be handled in the broader v0.6 roadmap

@adrien-bon adrien-bon deleted the feat/world branch January 6, 2025 20:10
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.

Handle Tiled world loading
2 participants