STLLoader: closes https://github.com/assimp/assimp/issues/1660: use memcpy instead of a c-style dynamic cast to parse a aiVector3D

pull/1715/head
Kim Kulling 2018-01-16 16:31:15 +01:00
parent d0bf5c10f9
commit d230635ff6
1 changed files with 11 additions and 9 deletions

View File

@ -444,27 +444,29 @@ bool STLImporter::LoadBinaryFile()
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
// our fault ... the RemoveInvalidData helper step should fix that
*vn = *((aiVector3D*)sz);
::memcpy( vn, sz, sizeof( aiVector3D ) );
sz += sizeof(aiVector3D);
*(vn+1) = *vn;
*(vn+2) = *vn;
vn += 3;
*vp++ = *((aiVector3D*)sz);
::memcpy( vp, sz, sizeof( aiVector3D ) );
++vp;
sz += sizeof(aiVector3D);
*vp++ = *((aiVector3D*)sz);
::memcpy( vp, sz, sizeof( aiVector3D ) );
++vp;
sz += sizeof(aiVector3D);
*vp++ = *((aiVector3D*)sz);
::memcpy( vp, sz, sizeof( aiVector3D ) );
++vp;
sz += sizeof(aiVector3D);
uint16_t color = *((uint16_t*)sz);