Resolve references inside USDZ packages#122
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR completes in-archive resolution for USDZ packages so that references/sublayers authored inside a .usdz can target sibling layers within the same archive (e.g. Pixar Kitchen_set.usdz), composing packaged sub-assets through the normal resolver + layer registry pipeline.
Changes:
- Anchor bare
.usdzasset paths to the archive’s first layer viaar::Resolver::resolve, and makecreate_identifieranchor relative asset paths within the enclosing package. - Teach
ResolvedPath::extension()and the USDZ archive reader to correctly identify inner-layer formats (including content-sniffing for.usd). - Remove the previous “unsupported in-package reference” guardrails and update tests to assert successful composition instead of error reporting.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/stage.rs | Updates integration test to assert in-package reference resolution and composed opinions. |
| src/usdz/reader.rs | Adds content-based format detection for inner .usd (USDC magic vs USDA text). |
| src/usdz/mod.rs | Adjusts USDZ FileFormat::read handling and adds a focused unit test for packaged references. |
| src/sdf/layer_registry.rs | Removes the previous USDZ sublayer bail-out and documents the new in-package resolution behavior. |
| src/pcp/prim_indexer.rs | Removes the explicit UnsupportedUsdzReference error emission path. |
| src/pcp/mod.rs | Deletes the UnsupportedUsdzReference error variant. |
| src/ar.rs | Implements package anchoring in resolve, package-relative extension handling, and package-aware identifier anchoring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Give Layer a resolved real_path (C++ SdfLayer::GetRealPath) distinct from its identifier, and anchor every in-package reference, sublayer, and asset path against it. A package whose default layer lives in a sub-directory previously lost that prefix when anchoring relative paths; it now resolves in-package correctly. The bare-package -> default-layer decision moves out of the generic resolver into a FileFormat::resolve_layer hook, so resolve() stays package-agnostic (asset-value resolution and the resolvability probe get the package path itself) while usdz owns its own package rule. Package-internal joins now emit forward slashes and collapse '..' to match ZIP entry names on every platform, and a nested package-relative target nests well-formed instead of forming a double-bracket identifier. A package that cannot be opened, or lists no default layer, falls back to its bare path so read() surfaces the precise zip/parse error consistently rather than reporting a missing asset. Also record the architectural-correctness preference in CLAUDE.md.
Owner
|
Thanks! |
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.
When I added the USDZ reader earlier it only read the package's first layer - references to other layers inside the same archive were never resolved. So opening something like Pixar's
Kitchen_set.usdzcomposed the root but dropped every packaged sub-asset (untyped prims, no geometry), and composition reportedUnsupportedUsdzReference/ the eager collector bailed. My miss - this finishes it (completes ROADMAP 9.7 "Packaged resources").What it does
Anchors a bare
.usdzto its first layer in the resolver (pkg.usdz[first.usd], like C++ Ar), so a package composes through the normal path:resolve()maps a bare.usdz-> its first packaged layer, uniformly for a root, sublayer, or referenced.usdz.create_identifieranchors a relative reference into the enclosing package.ResolvedPath::extension()reads the inner extension for package-relative paths.UsdzFileFormat::readaccepts either a package or a package-relative path..usdinner layer (USDC magic vs USDA text), so a package whose root layer is.usdopens.UnsupportedUsdzReferenceguard/variant (cross-file refs now resolve).Reads the package directory through the resolver's own
open_assetrather than direct filesystem access, so a future host-provided byte source (#105's "get me the bytes for this layer") flows through unchanged - sync-only, no async, no new deps.I put the package -> default-layer anchoring in
ar::Resolver::resolve. C++ does this at theSdfLayertier, soLayerRegistrymight be the more faithful...