Merge pull request #1314 from jamesgk/gltf-export

GLTF exporter: ensure buffer view byte offsets are correctly aligned
pull/1318/head
Kim Kulling 2017-06-22 08:31:07 +02:00 committed by GitHub
commit 6aca0f86b4
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); unsigned int bytesPerComp = ComponentTypeSize(compType);
size_t offset = buffer->byteLength; 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; size_t length = count * numCompsOut * bytesPerComp;
buffer->Grow(length); buffer->Grow(length + padding);
// bufferView // bufferView
Ref<BufferView> bv = a.bufferViews.Create(a.FindUniqueID(meshName, "view")); Ref<BufferView> bv = a.bufferViews.Create(a.FindUniqueID(meshName, "view"));