Repository navigation
fix(assets): preserve companion file paths and migrate existing flat textures - #64
Merged
Merged
Conversation
The Poly Haven API includes companion file relative paths as inc.Key (e.g. 'textures/foo_diff_4k.jpg', 'foo.bin'). The previous code only stored the URL and derived the filename via Path.GetFileName, dropping the subdirectory prefix entirely. All textures were placed flat next to the primary model, breaking GLTF/FBX/Blend/USD texture references. - AssetFormatOption: replace CompanionUrls List<string> with CompanionFiles List<(string RelativePath, string Url)> - LoadAssetFormatsAsync: store (inc.Key, url) instead of url only - LoadAndDownloadAssetAsync: use RelativePath verbatim relative to destDir, creating subdirectories (e.g. textures/) as needed
…artup Existing downloaded assets have textures sitting flat next to the primary model file instead of in a textures/ subdirectory, breaking GLTF/FBX/Blend/USD texture references. MigrateAssetFoldersAsync runs once at startup in the background: it collects all flat image files (jpg/jpeg/png/webp/hdr/exr) under AppPaths.Assets, moves them into the textures/ subdirectory alongside their primary model, and notifies the user with toasts before and after. Dirs that are already correctly structured are skipped. Non-fatal — any individual move failure leaves the file in place.
…eption Directory.EnumerateFiles with SearchOption.AllDirectories throws when it walks into protected system paths (e.g. Photos Library.photoslibrary) if the user sets the engine install location to a broad directory like their home folder. Catch IOException and UnauthorizedAccessException at both the top-level directory scan and per-version file search so the scan completes gracefully instead of crashing the app.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Poly Haven API returns companion file relative paths as
inc.Key(e.g.textures/foo_diff_4k.jpg,foo.bin). The previous code only stored the URL and derived the filename viaPath.GetFileName, silently dropping the subdirectory prefix. All textures were placed flat next to the primary model file, breaking texture references in GLTF, FBX, Blend, and USD files.Changes
Fix: new downloads use correct structure
AssetFormatOption:CompanionUrls List<string>→CompanionFiles List<(RelativePath, Url)>LoadAssetFormatsAsync: store(inc.Key, url)instead ofurlonlyLoadAndDownloadAssetAsync: useRelativePathverbatim relative todestDir, creating subdirectories (textures/) as neededFix: background migration for existing assets
MigrateAssetFoldersAsyncruns once at startup in the backgroundjpg/jpeg/png/webp/hdr/exr) underAppPaths.Assetstextures/alongside their primary model fileResult
Verified against GLTF (
wine_barrel_01,chandelier_03), FBX, Blend — all formats usetextures/consistently per the Poly Haven API.