Merge pull request #1827 from JeffH-BMG/patch-1
Fix import of binary STL files in double-precision buildspull/1573/merge
commit
72800bf072
|
@ -449,26 +449,43 @@ bool STLImporter::LoadBinaryFile()
|
|||
aiVector3D *vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
|
||||
aiVector3D *vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
|
||||
|
||||
typedef aiVector3t<float> aiVector3F;
|
||||
aiVector3F* theVec;
|
||||
aiVector3F theVec3F;
|
||||
|
||||
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
|
||||
::memcpy( vn, sz, sizeof( aiVector3D ) );
|
||||
sz += sizeof(aiVector3D);
|
||||
|
||||
// There's one normal for the face in the STL; use it three times
|
||||
// for vertex normals
|
||||
theVec = (aiVector3F*) sz;
|
||||
::memcpy( &theVec3F, theVec, sizeof(aiVector3F) );
|
||||
vn->x = theVec3F.x; vn->y = theVec3F.y; vn->z = theVec3F.z;
|
||||
*(vn+1) = *vn;
|
||||
*(vn+2) = *vn;
|
||||
++theVec;
|
||||
vn += 3;
|
||||
|
||||
::memcpy( vp, sz, sizeof( aiVector3D ) );
|
||||
// vertex 1
|
||||
::memcpy( &theVec3F, theVec, sizeof(aiVector3F) );
|
||||
vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z;
|
||||
++theVec;
|
||||
++vp;
|
||||
sz += sizeof(aiVector3D);
|
||||
|
||||
::memcpy( vp, sz, sizeof( aiVector3D ) );
|
||||
// vertex 2
|
||||
::memcpy( &theVec3F, theVec, sizeof(aiVector3F) );
|
||||
vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z;
|
||||
++theVec;
|
||||
++vp;
|
||||
sz += sizeof(aiVector3D);
|
||||
|
||||
::memcpy( vp, sz, sizeof( aiVector3D ) );
|
||||
// vertex 3
|
||||
::memcpy( &theVec3F, theVec, sizeof(aiVector3F) );
|
||||
vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z;
|
||||
++theVec;
|
||||
++vp;
|
||||
sz += sizeof(aiVector3D);
|
||||
|
||||
sz = (const unsigned char*) theVec;
|
||||
|
||||
uint16_t color = *((uint16_t*)sz);
|
||||
sz += 2;
|
||||
|
|
Loading…
Reference in New Issue