mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Fix array timeSamples printing for Value-based storage
Array timeSamples read from USDC files use add_value_array_sample() which stores data in _samples vector (Value-based storage) rather than in unified POD storage buffers (_values/_small_values/_offsets). The printing code was checking if _times was non-empty to decide whether to use POD unified storage path, but this check was insufficient because add_value_array_sample() populates _times while storing data in _samples. Fixed by checking if unified storage buffers actually contain data before using the POD path. If _times is populated but all storage buffers are empty, fall through to the Value-based printing path. This fixes ~17 test files with array timeSamples that were showing "/* empty value data */" instead of actual array values. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1422,8 +1422,16 @@ void pprint_timesamples(StreamWriter& writer, const value::TimeSamples& samples,
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if using unified storage (_times non-empty) vs legacy Sample-based storage
|
||||
if (!samples.get_times().empty()) {
|
||||
// Check if using unified storage (_times non-empty AND has actual data in buffers)
|
||||
// vs Sample-based storage (_samples vector)
|
||||
// Note: Some operations like add_value_array_sample() populate _times but store data
|
||||
// in _samples, so we need to check if unified storage buffers actually have data
|
||||
bool has_unified_data = !samples.get_times().empty() &&
|
||||
(!samples.get_values().empty() ||
|
||||
!samples.get_small_values().empty() ||
|
||||
!samples.get_offsets().empty());
|
||||
|
||||
if (has_unified_data) {
|
||||
|
||||
// Phase 3: Access unified storage directly from TimeSamples
|
||||
// Note: TypedArray is no longer supported in Phase 3, so we skip that path
|
||||
|
||||
Reference in New Issue
Block a user