GLTF exporter: ensure buffer view byte offsets are correctly aligned

pull/1314/head
jamesgk 2017-06-20 14:15:41 -07:00
parent 3ed08971c4
commit 7e45c63901
1 changed files with 4 additions and 1 deletions

View File

@ -185,8 +185,11 @@ inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& bu
unsigned int bytesPerComp = ComponentTypeSize(compType);
size_t offset = buffer->byteLength;
// make sure offset is correctly byte-aligned, as required by spec
size_t padding = offset % bytesPerComp;
offset += padding;
size_t length = count * numCompsOut * bytesPerComp;
buffer->Grow(length);
buffer->Grow(length + padding);
// bufferView
Ref<BufferView> bv = a.bufferViews.Create(a.FindUniqueID(meshName, "view"));