Respond to comments
Use memcpy() to read normals and vertices, to mitigate alignment issues, per comments.pull/1827/head
parent
6fd64b95c3
commit
89a4cf9495
|
@ -451,6 +451,7 @@ bool STLImporter::LoadBinaryFile()
|
||||||
|
|
||||||
typedef aiVector3t<float> aiVector3F;
|
typedef aiVector3t<float> aiVector3F;
|
||||||
aiVector3F* theVec;
|
aiVector3F* theVec;
|
||||||
|
aiVector3F theVec3F;
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < pMesh->mNumFaces; ++i ) {
|
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
|
||||||
|
@ -459,19 +460,32 @@ bool STLImporter::LoadBinaryFile()
|
||||||
// There's one normal for the face in the STL; use it three times
|
// There's one normal for the face in the STL; use it three times
|
||||||
// for vertex normals
|
// for vertex normals
|
||||||
theVec = (aiVector3F*) sz;
|
theVec = (aiVector3F*) sz;
|
||||||
*vn++ = *theVec;
|
::memcpy( &theVec3F, theVec, sizeof(aiVector3F) );
|
||||||
*vn++ = *theVec;
|
vn->x = theVec3F.x; vn->y = theVec3F.y; vn->z = theVec3F.z;
|
||||||
*vn++ = *theVec++;
|
*(vn+1) = *vn;
|
||||||
|
*(vn+2) = *vn;
|
||||||
|
++theVec;
|
||||||
|
vn += 3;
|
||||||
|
|
||||||
// vertex 1
|
// vertex 1
|
||||||
*vp++ = *theVec++;
|
::memcpy( &theVec3F, theVec, sizeof(aiVector3F) );
|
||||||
|
vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z;
|
||||||
|
++theVec;
|
||||||
|
++vp;
|
||||||
|
|
||||||
// vertex 2
|
// vertex 2
|
||||||
*vp++ = *theVec++;
|
::memcpy( &theVec3F, theVec, sizeof(aiVector3F) );
|
||||||
|
vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z;
|
||||||
|
++theVec;
|
||||||
|
++vp;
|
||||||
|
|
||||||
// vertex 3
|
// vertex 3
|
||||||
*vp++ = *theVec;
|
::memcpy( &theVec3F, theVec, sizeof(aiVector3F) );
|
||||||
sz += 4 * sizeof( aiVector3F );
|
vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z;
|
||||||
|
++theVec;
|
||||||
|
++vp;
|
||||||
|
|
||||||
|
sz = theVec;
|
||||||
|
|
||||||
uint16_t color = *((uint16_t*)sz);
|
uint16_t color = *((uint16_t*)sz);
|
||||||
sz += 2;
|
sz += 2;
|
||||||
|
|
Loading…
Reference in New Issue