Skip to content

Commit

Permalink
Normalize paths when converting from LDtk -> Asset path.
Browse files Browse the repository at this point in the history
This avoids creating duplicate assets when the LDTK project is in a subdirectory. May not be compatible with very complex asset hierarchies involving symlinks.

Trouv#240
  • Loading branch information
focustense committed Oct 14, 2023
1 parent 9a10bc8 commit 7b01896
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ hex = "0.4"
anyhow = "1.0"
thiserror = "1.0"
paste = "1.0"
path-clean = "1.0.1"

[dev-dependencies]
bevy = "0.11"
Expand Down
8 changes: 7 additions & 1 deletion src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ use bevy::{
render::render_resource::{Extent3d, TextureDimension, TextureFormat},
utils::BoxedFuture,
};
use path_clean::PathClean;
use std::{collections::HashMap, path::Path};

#[allow(unused_imports)]
use crate::components::LdtkWorldBundle;

fn ldtk_path_to_asset_path<'b>(ldtk_path: &Path, rel_path: &str) -> AssetPath<'b> {
ldtk_path.parent().unwrap().join(Path::new(rel_path)).into()
ldtk_path
.parent()
.unwrap()
.join(Path::new(rel_path))
.clean()
.into()
}

/// Used in [LdtkAsset]. Key is the tileset definition uid.
Expand Down

0 comments on commit 7b01896

Please sign in to comment.