MDCLoader: Fix horrible pointer casting hack

pull/1647/head
Turo Lamminen 2017-12-19 18:55:14 +02:00
parent 0cf772a4d4
commit 47b725a8c8
1 changed files with 4 additions and 9 deletions

View File

@ -283,9 +283,8 @@ void MDCImporter::InternReadFile(
pcMesh->mNumVertices = pcMesh->mNumFaces * 3;
// store the name of the surface for use as node name.
// FIX: make sure there is a 0 termination
const_cast<char&>(pcSurface->ucName[AI_MDC_MAXQPATH-1]) = '\0';
pcMesh->mTextureCoords[3] = (aiVector3D*)pcSurface->ucName;
pcMesh->mName.Set(std::string(pcSurface->ucName
, strnlen(pcSurface->ucName, AI_MDC_MAXQPATH - 1)));
// go to the first shader in the file. ignore the others.
if (pcSurface->ulNumShaders)
@ -432,7 +431,7 @@ void MDCImporter::InternReadFile(
else if (1 == pScene->mNumMeshes)
{
pScene->mRootNode = new aiNode();
pScene->mRootNode->mName.Set(std::string((const char*)pScene->mMeshes[0]->mTextureCoords[3]));
pScene->mRootNode->mName = pScene->mMeshes[0]->mName;
pScene->mRootNode->mNumMeshes = 1;
pScene->mRootNode->mMeshes = new unsigned int[1];
pScene->mRootNode->mMeshes[0] = 0;
@ -447,17 +446,13 @@ void MDCImporter::InternReadFile(
{
aiNode* pcNode = pScene->mRootNode->mChildren[i] = new aiNode();
pcNode->mParent = pScene->mRootNode;
pcNode->mName.Set(std::string((const char*)pScene->mMeshes[i]->mTextureCoords[3]));
pcNode->mName = pScene->mMeshes[i]->mName;
pcNode->mNumMeshes = 1;
pcNode->mMeshes = new unsigned int[1];
pcNode->mMeshes[0] = i;
}
}
// make sure we invalidate the pointer to the mesh name
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
pScene->mMeshes[i]->mTextureCoords[3] = NULL;
// create materials
pScene->mNumMaterials = (unsigned int)aszShaders.size();
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];