diff --git a/code/3DSConverter.cpp b/code/3DSConverter.cpp index e54911b2f..c7085b8dd 100644 --- a/code/3DSConverter.cpp +++ b/code/3DSConverter.cpp @@ -131,20 +131,20 @@ void Dot3DSImporter::CheckIndices(Dot3DS::Mesh* sMesh) i != sMesh->mFaces.end();++i) { // check whether all indices are in range - if ((*i).a.b.i1 >= sMesh->mPositions.size()) + if ((*i).mIndices[0] >= sMesh->mPositions.size()) { DefaultLogger::get()->warn("Face index overflow in 3DS file (#1)"); - (*i).a.b.i1 = sMesh->mPositions.size()-1; + (*i).mIndices[0] = sMesh->mPositions.size()-1; } - if ((*i).a.b.i2 >= sMesh->mPositions.size()) + if ((*i).mIndices[1] >= sMesh->mPositions.size()) { DefaultLogger::get()->warn("Face index overflow in 3DS file (#2)"); - (*i).a.b.i2 = sMesh->mPositions.size()-1; + (*i).mIndices[1] = sMesh->mPositions.size()-1; } - if ((*i).a.b.i3 >= sMesh->mPositions.size()) + if ((*i).mIndices[2] >= sMesh->mPositions.size()) { DefaultLogger::get()->warn("Face index overflow in 3DS file (#3)"); - (*i).a.b.i3 = sMesh->mPositions.size()-1; + (*i).mIndices[2] = sMesh->mPositions.size()-1; } } return; @@ -169,20 +169,20 @@ void Dot3DSImporter::MakeUnique(Dot3DS::Mesh* sMesh) uint32_t iTemp1,iTemp2; // position and texture coordinates - vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i3]; - vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].a.b.i3]; + vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[2]]; + vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].mIndices[2]]; iTemp1 = iBase++; - vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i2]; - vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].a.b.i2]; + vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[1]]; + vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].mIndices[1]]; iTemp2 = iBase++; - vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i1]; - vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].a.b.i1]; - sMesh->mFaces[i].a.b.i3 = iBase++; + vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[0]]; + vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].mIndices[0]]; + sMesh->mFaces[i].mIndices[2] = iBase++; - sMesh->mFaces[i].a.b.i1 = iTemp1; - sMesh->mFaces[i].a.b.i2 = iTemp2; + sMesh->mFaces[i].mIndices[0] = iTemp1; + sMesh->mFaces[i].mIndices[1] = iTemp2; // handle the face order ... /*if (iTemp1 > iTemp2) @@ -198,17 +198,17 @@ void Dot3DSImporter::MakeUnique(Dot3DS::Mesh* sMesh) uint32_t iTemp1,iTemp2; // position only - vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i3]; + vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[2]]; iTemp1 = iBase++; - vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i2]; + vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[1]]; iTemp2 = iBase++; - vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i1]; - sMesh->mFaces[i].a.b.i3 = iBase++; + vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[0]]; + sMesh->mFaces[i].mIndices[2] = iBase++; - sMesh->mFaces[i].a.b.i1 = iTemp1; - sMesh->mFaces[i].a.b.i2 = iTemp2; + sMesh->mFaces[i].mIndices[0] = iTemp1; + sMesh->mFaces[i].mIndices[1] = iTemp2; // handle the face order ... /*if (iTemp1 > iTemp2) @@ -451,16 +451,16 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut) p_pcOut->mFaces[q].mNumIndices = 3; p_pcOut->mFaces[q].mIndices[2] = iBase; - p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].a.b.i1]; - p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].a.b.i1]; + p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].mIndices[0]]; + p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].mIndices[0]]; p_pcOut->mFaces[q].mIndices[1] = iBase; - p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].a.b.i2]; - p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].a.b.i2]; + p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].mIndices[1]]; + p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].mIndices[1]]; p_pcOut->mFaces[q].mIndices[0] = iBase; - p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].a.b.i3]; - p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].a.b.i3]; + p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].mIndices[2]]; + p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].mIndices[2]]; } } // convert texture coordinates @@ -473,15 +473,15 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut) { unsigned int iIndex2 = aiSplit[p][q]; - unsigned int iIndex = (*i).mFaces[iIndex2].a.b.i1; + unsigned int iIndex = (*i).mFaces[iIndex2].mIndices[0]; aiVector2D& pc = (*i).mTexCoords[iIndex]; p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f); - iIndex = (*i).mFaces[iIndex2].a.b.i2; + iIndex = (*i).mFaces[iIndex2].mIndices[1]; pc = (*i).mTexCoords[iIndex]; p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f); - iIndex = (*i).mFaces[iIndex2].a.b.i3; + iIndex = (*i).mFaces[iIndex2].mIndices[2]; pc = (*i).mTexCoords[iIndex]; p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f); } diff --git a/code/3DSGenNormals.cpp b/code/3DSGenNormals.cpp index 4b0536bb6..995d5315e 100644 --- a/code/3DSGenNormals.cpp +++ b/code/3DSGenNormals.cpp @@ -62,17 +62,17 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh) Dot3DS::Face& face = sMesh->mFaces[a]; // assume it is a triangle - aiVector3D* pV1 = &sMesh->mPositions[face.a.b.i1]; - aiVector3D* pV2 = &sMesh->mPositions[face.a.b.i2]; - aiVector3D* pV3 = &sMesh->mPositions[face.a.b.i3]; + aiVector3D* pV1 = &sMesh->mPositions[face.mIndices[0]]; + aiVector3D* pV2 = &sMesh->mPositions[face.mIndices[1]]; + aiVector3D* pV3 = &sMesh->mPositions[face.mIndices[2]]; aiVector3D pDelta1 = *pV2 - *pV1; aiVector3D pDelta2 = *pV3 - *pV1; aiVector3D vNor = pDelta1 ^ pDelta2; - sMesh->mNormals[face.a.b.i1] = vNor; - sMesh->mNormals[face.a.b.i2] = vNor; - sMesh->mNormals[face.a.b.i3] = vNor; + sMesh->mNormals[face.mIndices[0]] = vNor; + sMesh->mNormals[face.mIndices[1]] = vNor; + sMesh->mNormals[face.mIndices[2]] = vNor; } // calculate the position bounds so we have a reliable epsilon to @@ -111,7 +111,7 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh) for (unsigned int c = 0; c < 3;++c) { - sSort.FindPositions(sMesh->mPositions[(*i).a.mIndices[c]],(*i).iSmoothGroup, + sSort.FindPositions(sMesh->mPositions[(*i).mIndices[c]],(*i).iSmoothGroup, posEpsilon,poResult); aiVector3D vNormals; @@ -127,7 +127,7 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh) vNormals.y /= fDiv; vNormals.z /= fDiv; vNormals.Normalize(); - avNormals[(*i).a.mIndices[c]] = vNormals; + avNormals[(*i).mIndices[c]] = vNormals; poResult.clear(); } } diff --git a/code/3DSHelper.h b/code/3DSHelper.h index 40c2bd83c..ff3c02748 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -308,25 +308,16 @@ struct Face Face() : iSmoothGroup(0), bFlipped(false) { // let the rest uninitialized for performance - this->a.b.i1 = 0; - this->a.b.i2 = 0; - this->a.b.i3 = 0; + this->mIndices[0] = 0; + this->mIndices[1] = 0; + this->mIndices[2] = 0; } //! Indices. .3ds is using uint16. However, after //! an unique vrtex set has been geneerated it might //! be an index becomes > 2^16 - union - { - struct - { - uint32_t i1; - uint32_t i2; - uint32_t i3; - } b; // DUMMY NAME - uint32_t mIndices[3]; - } a; // DUMMY NAME + uint32_t mIndices[3]; //! specifies to which smoothing group the face belongs to uint32_t iSmoothGroup; diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index bd22e4dd0..212b1d868 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -983,11 +983,11 @@ void Dot3DSImporter::ParseMeshChunk(int* piRemaining) while (iNum-- > 0) { Dot3DS::Face sFace; - sFace.a.b.i1 = *((uint16_t*)this->mCurrent); + sFace.mIndices[0] = *((uint16_t*)this->mCurrent); this->mCurrent += sizeof(uint16_t); - sFace.a.b.i2 = *((uint16_t*)this->mCurrent); + sFace.mIndices[1] = *((uint16_t*)this->mCurrent); this->mCurrent += sizeof(uint16_t); - sFace.a.b.i3 = *((uint16_t*)this->mCurrent); + sFace.mIndices[2] = *((uint16_t*)this->mCurrent); this->mCurrent += 2*sizeof(uint16_t); mMesh.mFaces.push_back(sFace); } diff --git a/code/3DSSpatialSort.cpp b/code/3DSSpatialSort.cpp index 0fca99d6e..632550989 100644 --- a/code/3DSSpatialSort.cpp +++ b/code/3DSSpatialSort.cpp @@ -73,18 +73,18 @@ void D3DSSpatialSorter::AddFace(const Dot3DS::Face* pcFace, ai_assert(NULL != pcFace); // store position by index and distance - float distance = vPositions[pcFace->a.b.i1] * mPlaneNormal; - mPositions.push_back( Entry( pcFace->a.b.i1, vPositions[pcFace->a.b.i1], + float distance = vPositions[pcFace->mIndices[0]] * mPlaneNormal; + mPositions.push_back( Entry( pcFace->mIndices[0], vPositions[pcFace->mIndices[0]], distance, pcFace->iSmoothGroup)); // triangle vertex 2 - distance = vPositions[pcFace->a.b.i2] * mPlaneNormal; - mPositions.push_back( Entry( pcFace->a.b.i2, vPositions[pcFace->a.b.i2], + distance = vPositions[pcFace->mIndices[1]] * mPlaneNormal; + mPositions.push_back( Entry( pcFace->mIndices[1], vPositions[pcFace->mIndices[1]], distance, pcFace->iSmoothGroup)); // triangle vertex 3 - distance = vPositions[pcFace->a.b.i3] * mPlaneNormal; - mPositions.push_back( Entry( pcFace->a.b.i3, vPositions[pcFace->a.b.i3], + distance = vPositions[pcFace->mIndices[2]] * mPlaneNormal; + mPositions.push_back( Entry( pcFace->mIndices[2], vPositions[pcFace->mIndices[2]], distance, pcFace->iSmoothGroup)); } // ------------------------------------------------------------------------------------------------ diff --git a/code/ASELoader.cpp b/code/ASELoader.cpp index e7114af85..ebc0e92e7 100644 --- a/code/ASELoader.cpp +++ b/code/ASELoader.cpp @@ -286,7 +286,7 @@ void ASEImporter::BuildUniqueRepresentation(ASE::Mesh& mesh) { for (unsigned int n = 0; n < 3;++n,++iCurrent) { - mPositions[iCurrent] = mesh.mPositions[(*i).a.mIndices[n]]; + mPositions[iCurrent] = mesh.mPositions[(*i).mIndices[n]]; // add texture coordinates for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) @@ -304,20 +304,20 @@ void ASEImporter::BuildUniqueRepresentation(ASE::Mesh& mesh) // add normal vectors if (!mesh.mNormals.empty()) { - mNormals[iCurrent] = mesh.mNormals[(*i).a.mIndices[n]]; + mNormals[iCurrent] = mesh.mNormals[(*i).mIndices[n]]; } // handle bone vertices - if ((*i).a.mIndices[n] < mesh.mBoneVertices.size()) + if ((*i).mIndices[n] < mesh.mBoneVertices.size()) { // (sometimes this will cause bone verts to be duplicated // however, I' quite sure Schrompf' JoinVerticesStep // will fix that again ...) - mBoneVertices[iCurrent] = mesh.mBoneVertices[(*i).a.mIndices[n]]; + mBoneVertices[iCurrent] = mesh.mBoneVertices[(*i).mIndices[n]]; } // assign a new valid index to the face - (*i).a.mIndices[n] = iCurrent; + (*i).mIndices[n] = iCurrent; } } @@ -577,7 +577,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene) for (unsigned int t = 0; t < 3;++t) { - const uint32_t iIndex2 = mesh.mFaces[iIndex].a.mIndices[t]; + const uint32_t iIndex2 = mesh.mFaces[iIndex].mIndices[t]; p_pcOut->mVertices[iBase] = mesh.mPositions[iIndex2]; p_pcOut->mNormals[iBase] = mesh.mNormals[iIndex2]; @@ -618,7 +618,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene) unsigned int iIndex = aiSplit[p][q]; for (unsigned int t = 0; t < 3;++t) { - p_pcOut->mTextureCoords[c][iBase++] = mesh.amTexCoords[c][mesh.mFaces[iIndex].a.mIndices[t]]; + p_pcOut->mTextureCoords[c][iBase++] = mesh.amTexCoords[c][mesh.mFaces[iIndex].mIndices[t]]; } } // setup the number of valid vertex components @@ -636,7 +636,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene) unsigned int iIndex = aiSplit[p][q]; for (unsigned int t = 0; t < 3;++t) { - p_pcOut->mColors[0][iBase++] = mesh.mVertexColors[mesh.mFaces[iIndex].a.mIndices[t]]; + p_pcOut->mColors[0][iBase++] = mesh.mVertexColors[mesh.mFaces[iIndex].mIndices[t]]; } } } @@ -738,9 +738,9 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene) p_pcOut->mFaces[iFace].mIndices = new unsigned int[3]; // copy indices - p_pcOut->mFaces[iFace].mIndices[0] = mesh.mFaces[iFace].a.mIndices[0]; - p_pcOut->mFaces[iFace].mIndices[1] = mesh.mFaces[iFace].a.mIndices[1]; - p_pcOut->mFaces[iFace].mIndices[2] = mesh.mFaces[iFace].a.mIndices[2]; + p_pcOut->mFaces[iFace].mIndices[0] = mesh.mFaces[iFace].mIndices[0]; + p_pcOut->mFaces[iFace].mIndices[1] = mesh.mFaces[iFace].mIndices[1]; + p_pcOut->mFaces[iFace].mIndices[2] = mesh.mFaces[iFace].mIndices[2]; } // copy vertex bones @@ -889,17 +889,17 @@ void ASEImporter::GenerateNormals(ASE::Mesh& mesh) const ASE::Face& face = mesh.mFaces[a]; // assume it is a triangle - aiVector3D* pV1 = &mesh.mPositions[face.a.b.i1]; - aiVector3D* pV2 = &mesh.mPositions[face.a.b.i2]; - aiVector3D* pV3 = &mesh.mPositions[face.a.b.i3]; + aiVector3D* pV1 = &mesh.mPositions[face.mIndices[0]]; + aiVector3D* pV2 = &mesh.mPositions[face.mIndices[1]]; + aiVector3D* pV3 = &mesh.mPositions[face.mIndices[2]]; aiVector3D pDelta1 = *pV2 - *pV1; aiVector3D pDelta2 = *pV3 - *pV1; aiVector3D vNor = pDelta1 ^ pDelta2; - mesh.mNormals[face.a.b.i1] = vNor; - mesh.mNormals[face.a.b.i2] = vNor; - mesh.mNormals[face.a.b.i3] = vNor; + mesh.mNormals[face.mIndices[0]] = vNor; + mesh.mNormals[face.mIndices[1]] = vNor; + mesh.mNormals[face.mIndices[2]] = vNor; } // calculate the position bounds so we have a reliable epsilon to @@ -934,7 +934,7 @@ void ASEImporter::GenerateNormals(ASE::Mesh& mesh) std::vector poResult; for (unsigned int c = 0; c < 3;++c) { - sSort.FindPositions(mesh.mPositions[(*i).a.mIndices[c]],(*i).iSmoothGroup, + sSort.FindPositions(mesh.mPositions[(*i).mIndices[c]],(*i).iSmoothGroup, posEpsilon,poResult); aiVector3D vNormals; @@ -948,7 +948,7 @@ void ASEImporter::GenerateNormals(ASE::Mesh& mesh) } vNormals.x /= fDiv;vNormals.y /= fDiv;vNormals.z /= fDiv; vNormals.Normalize(); - avNormals[(*i).a.mIndices[c]] = vNormals; + avNormals[(*i).mIndices[c]] = vNormals; poResult.clear(); } } diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index ea1a78d27..8ed32335c 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -1567,7 +1567,7 @@ __EARTHQUAKE_XXL: if(!SkipSpaces(this->m_szFile,&this->m_szFile)) BLUBB("Unable to parse *MESH_FACE Element: Unexpected EOL. Vertex index ecpected [#4]") - out.a.mIndices[iIndex] = strtol10(this->m_szFile,&this->m_szFile); + out.mIndices[iIndex] = strtol10(this->m_szFile,&this->m_szFile); } // now we need to skip the AB, BC, CA blocks.