GLTF exporter: ensure buffer view byte offsets are correctly aligned
parent
3ed08971c4
commit
7e45c63901
|
@ -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"));
|
||||||
|
|
Loading…
Reference in New Issue