Merge pull request #1712 from wanadev/gltf2-fixes

[glTF2] Fixed buffer alignment
pull/1716/head^2
Kim Kulling 2018-01-18 19:21:22 +01:00 committed by GitHub
commit 8358d585b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -485,7 +485,8 @@ uint8_t* new_data;
inline size_t Buffer::AppendData(uint8_t* data, size_t length)
{
size_t offset = this->byteLength;
Grow(length);
// Force alignment to 4 bits
Grow((length + 3) & ~3);
memcpy(mData.get() + offset, data, length);
return offset;
}

View File

@ -708,8 +708,13 @@ void glTF2Exporter::ExportMeshes()
if (v) p.attributes.position.push_back(v);
/******************** Normals ********************/
// Normalize all normals as the validator can emit a warning otherwise
for (auto i = 0u; i < aim->mNumVertices; ++i) {
aim->mNormals[i].Normalize();
}
Ref<Accessor> n = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mNormals, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
if (n) p.attributes.normal.push_back(n);
if (n) p.attributes.normal.push_back(n);
/************** Texture coordinates **************/
for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {