Add USD format support (usd, usda, usdc, usdz) using tinyusdz#1
Conversation
lanxinger
commented
Nov 5, 2025
- Integrated tinyusdz library for USD file loading
- Implemented load_usd_mesh() function with Tydra RenderScene conversion
- Added format detection for .usd, .usda, .usdc, and .usdz files
- Updated OpenMesh dependency to version 11.0.0
- Updated README with USD format documentation
- All meshes in USD files are combined and transforms applied automatically
- Integrated tinyusdz library for USD file loading - Implemented load_usd_mesh() function with Tydra RenderScene conversion - Added format detection for .usd, .usda, .usdc, and .usdz files - Updated OpenMesh dependency to version 11.0.0 - Updated README with USD format documentation - All meshes in USD files are combined and transforms applied automatically
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| bool load_usd_mesh(const std::string &filename, TriMesh &mesh, std::string &warning, std::string &error) | ||
| { | ||
| tinyusdz::Stage stage; | ||
| std::string warn, err; | ||
|
|
||
| // Load USD file based on extension | ||
| bool success = false; | ||
| if(has_extension(filename, ".usdz")){ | ||
| success = tinyusdz::LoadUSDZFromFile(filename, &stage, &warn, &err); | ||
| } | ||
| else if(has_extension(filename, ".usdc")){ | ||
| success = tinyusdz::LoadUSDCFromFile(filename, &stage, &warn, &err); | ||
| } | ||
| else if(has_extension(filename, ".usda")){ | ||
| success = tinyusdz::LoadUSDAFromFile(filename, &stage, &warn, &err); | ||
| } | ||
| else{ | ||
| error = "Unsupported USD file extension. Supported: .usdz, .usdc, .usda"; | ||
| return false; |
There was a problem hiding this comment.
Handle .usd extension in USD loader
The new load_usd_mesh() function only dispatches to tinyusdz loaders for .usdz, .usdc, and .usda, and otherwise immediately returns an error. However, main() and the README both claim that plain .usd files are supported and route .usd paths into load_usd_mesh(). Because of this mismatch every .usd input will fail with "Unsupported USD file extension" even though the feature is advertised. The loader should call the appropriate tinyusdz routine for .usd files instead of rejecting them.
Useful? React with 👍 / 👎.
The MeshSDFilter CMakeLists uses plain signature (without PRIVATE keyword), so we need to match that style for consistency.
The generic .usd extension can contain either ASCII or binary format. Use LoadUSDFromFile() which auto-detects the format. Fixes issue where .usd files were routed to load_usd_mesh() but then immediately rejected with 'Unsupported USD file extension' error.
- Use correct target name 'tinyusdz_static' instead of 'tinyusdz::tinyusdz_static' - Export TINYUSDZ_INCLUDE_DIR variable for clarity - Ensures tinyusdz headers are found during compilation
- Switched from manual FetchContent_Populate to FetchContent_MakeAvailable - Set tinyusdz build options before fetching (required for proper configuration) - Use tinyusdz_SOURCE_DIR directly for include paths - This should properly expose tinyusdz headers to MeshDenoiser target
The issue was timing - target_include_directories was called after the targets were compiled. By using include_directories() before add_subdirectory(), the include paths are available when MeshDenoiser.cpp is compiled. This ensures tinyusdz headers (tinyusdz.hh, tydra/*) are found during build.
The tydra namespace is nested as tinyusdz::tydra, not at the root level. Added 'using namespace tinyusdz' in the anonymous namespace to allow tydra:: to resolve correctly.
- Added tool description - Listed all supported input formats (OBJ, PLY, OFF, STL, glTF, USD) - Grouped formats by library for clarity - Added multiple usage examples showing format flexibility - More helpful for users discovering supported formats