Merge pull request #1715 from assimp/issue_1660

STLLoader: closes https://github.com/assimp/assimp/issues/1660: use m…
pull/1712/head^2
Kim Kulling 2018-01-16 17:47:22 +01:00 committed by GitHub
commit bedf506c0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -444,27 +444,29 @@ bool STLImporter::LoadBinaryFile()
pMesh->mNumVertices = pMesh->mNumFaces*3; pMesh->mNumVertices = pMesh->mNumFaces*3;
aiVector3D* vp,*vn;
vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
for (unsigned int i = 0; i < pMesh->mNumFaces;++i) { aiVector3D *vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
aiVector3D *vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
for ( unsigned int i = 0; i < pMesh->mNumFaces; ++i ) {
// NOTE: Blender sometimes writes empty normals ... this is not // NOTE: Blender sometimes writes empty normals ... this is not
// our fault ... the RemoveInvalidData helper step should fix that // our fault ... the RemoveInvalidData helper step should fix that
*vn = *((aiVector3D*)sz); ::memcpy( vn, sz, sizeof( aiVector3D ) );
sz += sizeof(aiVector3D); sz += sizeof(aiVector3D);
*(vn+1) = *vn; *(vn+1) = *vn;
*(vn+2) = *vn; *(vn+2) = *vn;
vn += 3; vn += 3;
*vp++ = *((aiVector3D*)sz); ::memcpy( vp, sz, sizeof( aiVector3D ) );
++vp;
sz += sizeof(aiVector3D); sz += sizeof(aiVector3D);
*vp++ = *((aiVector3D*)sz); ::memcpy( vp, sz, sizeof( aiVector3D ) );
++vp;
sz += sizeof(aiVector3D); sz += sizeof(aiVector3D);
*vp++ = *((aiVector3D*)sz); ::memcpy( vp, sz, sizeof( aiVector3D ) );
++vp;
sz += sizeof(aiVector3D); sz += sizeof(aiVector3D);
uint16_t color = *((uint16_t*)sz); uint16_t color = *((uint16_t*)sz);