diff --git a/code/XFileImporter.cpp b/code/XFileImporter.cpp index 94b38e303..ae847eef8 100644 --- a/code/XFileImporter.cpp +++ b/code/XFileImporter.cpp @@ -332,6 +332,11 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec // collect vertex data for indices of this face for( unsigned int d = 0; d < df.mNumIndices; ++d ) { df.mIndices[d] = newIndex; + const unsigned int newIdx( pf.mIndices[ d ] ); + if ( newIdx > sourceMesh->mPositions.size() ) { + continue; + } + orgPoints[newIndex] = pf.mIndices[d]; // Position @@ -459,7 +464,7 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData nbone->mNodeName.Set( bone->mBoneName); nanim->mChannels[b] = nbone; - // keyframes are given as combined transformation matrix keys + // key-frames are given as combined transformation matrix keys if( !bone->mTrafoKeys.empty() ) { nbone->mNumPositionKeys = (unsigned int)bone->mTrafoKeys.size(); diff --git a/code/XFileParser.cpp b/code/XFileParser.cpp index 0988edaff..e7bf8518c 100644 --- a/code/XFileParser.cpp +++ b/code/XFileParser.cpp @@ -471,7 +471,10 @@ void XFileParser::ParseDataObjectMesh( Mesh* pMesh) unsigned int numIndices = ReadInt(); Face& face = pMesh->mPosFaces[a]; for (unsigned int b = 0; b < numIndices; ++b) { - face.mIndices.push_back( ReadInt() ); + const int idx( ReadInt() ); + if ( static_cast( idx ) <= numVertices ) { + face.mIndices.push_back( idx ); + } } TestForSeparator(); } @@ -1293,7 +1296,7 @@ unsigned int XFileParser::ReadBinDWord() { // ------------------------------------------------------------------------------------------------ unsigned int XFileParser::ReadInt() { - if( mIsBinaryFormat) + if( mIsBinaryFormat) { if( mBinaryNumCount == 0 && mEnd - mP >= 2) { @@ -1305,7 +1308,8 @@ unsigned int XFileParser::ReadInt() } --mBinaryNumCount; - if ( mEnd - mP >= 4) { + const size_t len( mEnd - mP ); + if ( len >= 4) { return ReadBinDWord(); } else { mP = mEnd; @@ -1340,6 +1344,7 @@ unsigned int XFileParser::ReadInt() } CheckForSeparator(); + return isNegative ? ((unsigned int) -int( number)) : number; } } diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 156844a9b..041ab34c5 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -363,9 +363,7 @@ int CDisplay::ReplaceCurrentTexture(const char* szPath) *tex = piTexture; m_pcCurrentTexture->piTexture = tex; - //if (!pcMesh->bSharedFX){ - pcMesh->piEffect->SetTexture(tex_string,piTexture); - //} + pcMesh->piEffect->SetTexture(tex_string,piTexture); } } @@ -563,7 +561,6 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot, tvi.iImage = m_aiImageList[AI_VIEW_IMGLIST_MATERIAL]; tvi.iSelectedImage = m_aiImageList[AI_VIEW_IMGLIST_MATERIAL]; tvi.lParam = (LPARAM)10; - //tvi.state = TVIS_EXPANDED | TVIS_EXPANDEDONCE ; sNew.itemex = tvi; sNew.hInsertAfter = TVI_LAST; @@ -630,7 +627,7 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot, return 1; } //------------------------------------------------------------------------------- -// Expand all elements in the treeview +// Expand all elements in the tree-view int CDisplay::ExpandTree() { // expand all materials @@ -780,7 +777,7 @@ int CDisplay::OnRender() // Now render the log display in the upper right corner of the window CLogDisplay::Instance().OnRender(); - // present the backbuffer + // present the back-buffer g_piDevice->EndScene(); g_piDevice->Present(NULL,NULL,NULL,NULL); @@ -1601,7 +1598,7 @@ int CDisplay::HandleInput() return 1; } //------------------------------------------------------------------------------- -// Process input for an empty scen view to allow for skybox rotations +// Process input for an empty scene view to allow for sky-box rotations int CDisplay::HandleInputEmptyScene() { if(CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode()) @@ -2043,7 +2040,7 @@ int CDisplay::RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix, g_piDevice->SetVertexDeclaration( gDefaultVertexDecl); if (g_sOptions.bNoAlphaBlending) { - // manually disable alphablending + // manually disable alpha-blending g_piDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE); } @@ -2207,9 +2204,6 @@ int CDisplay::RenderTextureView() // it might be that there is no texture ... if (!m_pcCurrentTexture->piTexture) { - // FIX: no such log message. it would be repeated to often - //CLogDisplay::Instance().AddEntry("Unable to display texture. Image is unreachable.", - // D3DCOLOR_ARGB(0xFF,0xFF,0,0)); return 0; } @@ -2304,5 +2298,6 @@ int CDisplay::RenderTextureView() // do we need to draw UV coordinates? return 1; } -}; + +} diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index 33ca25799..746a4836f 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -183,7 +183,6 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter) // get the end time of zje operation, calculate delta t double fEnd = (double)timeGetTime(); g_fLoadTime = (float)((fEnd - fCur) / 1000); -// char szTemp[128]; g_bLoadingFinished = true; // check whether the loading process has failed ...