mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Fix asset path truncation and improve comparison test robustness
This commit fixes multiple issues discovered during USDA comparison testing: 1. Fix asset path truncation bug (src/value-pprint.cc) - Bug: Characters at end of asset paths were dropped when path contains '@' - Cause: Off-by-one error in boundary check logic - Impact: Asset paths like '0/teapot_@n.png' were truncated to '0/teapot_@n.p' - Fix: Moved boundary check into the '@@@' pattern detection condition - Result: Asset paths now print correctly, outputs match Pixar's usdcat 2. Improve comparison test suite (tests/compare-usda.js) - Increase parser depth limit from 100 to 10,000 for complex USD files - Increase iteration limit from 10,000 to 100,000 - Add filter to remove empty strings from glob expansion results - These changes allow skeleton and skeletal animation test files to parse 3. Add comprehensive analysis documentation - ERROR-ANALYSIS.md: Details of 7 error cases found - ASSET-PATH-BUG-ANALYSIS.md: Initial investigation of asset path issue - ASSET-PATH-FIX-SUMMARY.md: Root cause analysis and fix explanation Test suite improvements: - Before: 174 equivalent (91%), 10 different, 7 errors - After: 173 equivalent (91%), 13 different, 4 errors - Fixed: Asset path truncation completely, skeleton file parsing - Remaining: 4 errors due to comparison script limitations and reference tool Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -537,13 +537,12 @@ std::ostream &operator<<(std::ostream &ofs,
|
||||
if (tinyusdz::contains(in_s, '@')) {
|
||||
// Escape '@@@'(to '\@@@') if the input path contains '@@@'
|
||||
for (size_t i = 0; i < in_s.length(); i++) {
|
||||
if ((i + 2) < in_s.length()) {
|
||||
if (in_s[i] == '@' && in_s[i + 1] == '@' && in_s[i + 2] == '@') {
|
||||
s += "\\@@@";
|
||||
i += 2;
|
||||
} else {
|
||||
s += in_s[i];
|
||||
}
|
||||
if ((i + 2) < in_s.length() &&
|
||||
in_s[i] == '@' && in_s[i + 1] == '@' && in_s[i + 2] == '@') {
|
||||
s += "\\@@@";
|
||||
i += 2;
|
||||
} else {
|
||||
s += in_s[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -468,9 +468,9 @@ class UsdaParser {
|
||||
this.tokens = tokens;
|
||||
this.pos = 0;
|
||||
this.depth = 0;
|
||||
this.maxDepth = 100;
|
||||
this.maxDepth = 10000; // Very deep nesting for complex USD files (skeletal animation, etc.)
|
||||
this.iterations = 0;
|
||||
this.maxIterations = 10000;
|
||||
this.maxIterations = 100000;
|
||||
}
|
||||
|
||||
checkDepth() {
|
||||
@@ -1783,7 +1783,9 @@ function main() {
|
||||
// Mode 2: Run tusdcat and usdcat on input file(s) - supports glob patterns
|
||||
else if (options.files.length >= 1 && options.tusdcat && options.usdcat) {
|
||||
// Expand glob patterns
|
||||
const expandedFiles = expandFilePatterns(options.files, options.baseDir);
|
||||
const expandedFiles = expandFilePatterns(options.files, options.baseDir)
|
||||
// Filter out empty strings to prevent invalid file paths
|
||||
.filter(f => f && f.trim().length > 0);
|
||||
|
||||
if (expandedFiles.length === 0) {
|
||||
console.error('Error: No files found matching the pattern(s).');
|
||||
|
||||
Reference in New Issue
Block a user