Browse Source

glTF2: zero out extra space created by padding.

This makes resulting GLB deterministic.
Hill Ma 4 years ago
parent
commit
148b8c66a8
1 changed files with 3 additions and 1 deletions
  1. 3 1
      code/AssetLib/glTF2/glTF2Asset.inl

+ 3 - 1
code/AssetLib/glTF2/glTF2Asset.inl

@@ -790,8 +790,10 @@ inline bool Buffer::ReplaceData_joint(const size_t pBufferData_Offset, const siz
 inline size_t Buffer::AppendData(uint8_t *data, size_t length) {
     size_t offset = this->byteLength;
     // Force alignment to 4 bits
-    Grow((length + 3) & ~3);
+    size_t paddedLength = (length + 3) & ~3;
+    Grow(paddedLength);
     memcpy(mData.get() + offset, data, length);
+    memset(mData.get() + offset + length, 0, paddedLength - length);
     return offset;
 }