From 62847554c9abce257729f9f6c7071165ccd680a4 Mon Sep 17 00:00:00 2001 From: anwang2009 Date: Thu, 20 Feb 2025 09:02:42 -0800 Subject: [PATCH] Fix LocalizeAsset bug where assets bigger than 4096 characters are truncated in the output package (Internal change: 2357794) --- pxr/usd/usdUtils/localizeAsset.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pxr/usd/usdUtils/localizeAsset.cpp b/pxr/usd/usdUtils/localizeAsset.cpp index eca0281e56..dc9b204919 100644 --- a/pxr/usd/usdUtils/localizeAsset.cpp +++ b/pxr/usd/usdUtils/localizeAsset.cpp @@ -83,14 +83,16 @@ class UsdUtils_LocalizedAssetBuilder : public UsdUtils_AssetLocalizationPackage constexpr size_t COPY_BUFFER_SIZE = 4096U; char buffer[COPY_BUFFER_SIZE]; size_t dataRemaining = sourceAsset->GetSize(); + size_t offset = 0; while (dataRemaining > 0) { size_t chunkSize = std::min(dataRemaining, COPY_BUFFER_SIZE); - sourceAsset->Read(buffer, chunkSize, 0); - destAsset->Write(buffer, chunkSize, 0); + sourceAsset->Read(buffer, chunkSize, offset); + destAsset->Write(buffer, chunkSize, offset); dataRemaining -= chunkSize; + offset += chunkSize; } return true;