STLLoader: closes https://github.com/assimp/assimp/issues/1660: use memcpy instead of a c-style dynamic cast to parse a aiVector3D
parent
d0bf5c10f9
commit
d230635ff6
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue