Some review findings.

pull/1990/head
Kim Kulling 2018-05-31 20:15:13 +02:00
parent 8ecf3789d7
commit 339cc2e951
4 changed files with 22 additions and 17 deletions

View File

@ -332,6 +332,11 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
// collect vertex data for indices of this face // collect vertex data for indices of this face
for( unsigned int d = 0; d < df.mNumIndices; ++d ) { for( unsigned int d = 0; d < df.mNumIndices; ++d ) {
df.mIndices[d] = newIndex; df.mIndices[d] = newIndex;
const unsigned int newIdx( pf.mIndices[ d ] );
if ( newIdx > sourceMesh->mPositions.size() ) {
continue;
}
orgPoints[newIndex] = pf.mIndices[d]; orgPoints[newIndex] = pf.mIndices[d];
// Position // Position
@ -459,7 +464,7 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
nbone->mNodeName.Set( bone->mBoneName); nbone->mNodeName.Set( bone->mBoneName);
nanim->mChannels[b] = nbone; 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() ) if( !bone->mTrafoKeys.empty() )
{ {
nbone->mNumPositionKeys = (unsigned int)bone->mTrafoKeys.size(); nbone->mNumPositionKeys = (unsigned int)bone->mTrafoKeys.size();

View File

@ -471,7 +471,10 @@ void XFileParser::ParseDataObjectMesh( Mesh* pMesh)
unsigned int numIndices = ReadInt(); unsigned int numIndices = ReadInt();
Face& face = pMesh->mPosFaces[a]; Face& face = pMesh->mPosFaces[a];
for (unsigned int b = 0; b < numIndices; ++b) { for (unsigned int b = 0; b < numIndices; ++b) {
face.mIndices.push_back( ReadInt() ); const int idx( ReadInt() );
if ( idx <= numVertices ) {
face.mIndices.push_back( idx );
}
} }
TestForSeparator(); TestForSeparator();
} }
@ -1293,7 +1296,8 @@ unsigned int XFileParser::ReadBinDWord() {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
unsigned int XFileParser::ReadInt() unsigned int XFileParser::ReadInt()
{ {
if( mIsBinaryFormat) :
cd if( mIsBinaryFormat)
{ {
if( mBinaryNumCount == 0 && mEnd - mP >= 2) if( mBinaryNumCount == 0 && mEnd - mP >= 2)
{ {
@ -1305,6 +1309,7 @@ unsigned int XFileParser::ReadInt()
} }
--mBinaryNumCount; --mBinaryNumCount;
const size_t len( mEnd - mP );
if ( mEnd - mP >= 4) { if ( mEnd - mP >= 4) {
return ReadBinDWord(); return ReadBinDWord();
} else { } else {
@ -1340,6 +1345,7 @@ unsigned int XFileParser::ReadInt()
} }
CheckForSeparator(); CheckForSeparator();
return isNegative ? ((unsigned int) -int( number)) : number; return isNegative ? ((unsigned int) -int( number)) : number;
} }
} }

View File

@ -362,9 +362,7 @@ int CDisplay::ReplaceCurrentTexture(const char* szPath)
*tex = piTexture; *tex = piTexture;
m_pcCurrentTexture->piTexture = tex; m_pcCurrentTexture->piTexture = tex;
//if (!pcMesh->bSharedFX){ pcMesh->piEffect->SetTexture(tex_string,piTexture);
pcMesh->piEffect->SetTexture(tex_string,piTexture);
//}
} }
} }
@ -562,7 +560,6 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
tvi.iImage = m_aiImageList[AI_VIEW_IMGLIST_MATERIAL]; tvi.iImage = m_aiImageList[AI_VIEW_IMGLIST_MATERIAL];
tvi.iSelectedImage = m_aiImageList[AI_VIEW_IMGLIST_MATERIAL]; tvi.iSelectedImage = m_aiImageList[AI_VIEW_IMGLIST_MATERIAL];
tvi.lParam = (LPARAM)10; tvi.lParam = (LPARAM)10;
//tvi.state = TVIS_EXPANDED | TVIS_EXPANDEDONCE ;
sNew.itemex = tvi; sNew.itemex = tvi;
sNew.hInsertAfter = TVI_LAST; sNew.hInsertAfter = TVI_LAST;
@ -629,7 +626,7 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
return 1; return 1;
} }
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// Expand all elements in the treeview // Expand all elements in the tree-view
int CDisplay::ExpandTree() int CDisplay::ExpandTree()
{ {
// expand all materials // expand all materials
@ -779,7 +776,7 @@ int CDisplay::OnRender()
// Now render the log display in the upper right corner of the window // Now render the log display in the upper right corner of the window
CLogDisplay::Instance().OnRender(); CLogDisplay::Instance().OnRender();
// present the backbuffer // present the back-buffer
g_piDevice->EndScene(); g_piDevice->EndScene();
g_piDevice->Present(NULL,NULL,NULL,NULL); g_piDevice->Present(NULL,NULL,NULL,NULL);
@ -1593,7 +1590,7 @@ int CDisplay::HandleInput()
return 1; 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() int CDisplay::HandleInputEmptyScene()
{ {
if(CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode()) if(CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode())
@ -2035,7 +2032,7 @@ int CDisplay::RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
g_piDevice->SetVertexDeclaration( gDefaultVertexDecl); g_piDevice->SetVertexDeclaration( gDefaultVertexDecl);
if (g_sOptions.bNoAlphaBlending) { if (g_sOptions.bNoAlphaBlending) {
// manually disable alphablending // manually disable alpha-blending
g_piDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE); g_piDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
} }
@ -2199,9 +2196,6 @@ int CDisplay::RenderTextureView()
// it might be that there is no texture ... // it might be that there is no texture ...
if (!m_pcCurrentTexture->piTexture) 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; return 0;
} }
@ -2296,5 +2290,6 @@ int CDisplay::RenderTextureView()
// do we need to draw UV coordinates? // do we need to draw UV coordinates?
return 1; return 1;
} }
};
}

View File

@ -178,7 +178,6 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
// get the end time of zje operation, calculate delta t // get the end time of zje operation, calculate delta t
double fEnd = (double)timeGetTime(); double fEnd = (double)timeGetTime();
g_fLoadTime = (float)((fEnd - fCur) / 1000); g_fLoadTime = (float)((fEnd - fCur) / 1000);
// char szTemp[128];
g_bLoadingFinished = true; g_bLoadingFinished = true;
// check whether the loading process has failed ... // check whether the loading process has failed ...
@ -202,7 +201,7 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
int LoadAsset(void) int LoadAsset(void)
{ {
// set the world and world rotation matrices to the identuty // set the world and world rotation matrices to the identity
g_mWorldRotate = aiMatrix4x4(); g_mWorldRotate = aiMatrix4x4();
g_mWorld = aiMatrix4x4(); g_mWorld = aiMatrix4x4();