Bläddra i källkod

Fixes for some warnings in the gcc4 linux 64 build.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@134 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg 17 år sedan
förälder
incheckning
c9c2810e3c

+ 0 - 13
code/ASELoader.cpp

@@ -294,10 +294,6 @@ void ASEImporter::AddNodes(aiNode* pcParent,const char* szName,
 
 
 		// TODO: experimental quick'n'dirty, clean this up ...
 		// TODO: experimental quick'n'dirty, clean this up ...
 		std::string szMyName[2] = {mesh.mName,mesh.mParent} ;
 		std::string szMyName[2] = {mesh.mName,mesh.mParent} ;
-		if (!szMyName)
-		{
-			continue;
-		}
 		if (szName)
 		if (szName)
 		{
 		{
 			if( len != szMyName[1].length() ||
 			if( len != szMyName[1].length() ||
@@ -375,11 +371,6 @@ void ASEImporter::BuildNodes()
 		// TODO: experimental quick'n'dirty, clean this up ...
 		// TODO: experimental quick'n'dirty, clean this up ...
 		std::string szMyName[2] = {mesh.mName,mesh.mParent} ;
 		std::string szMyName[2] = {mesh.mName,mesh.mParent} ;
 
 
-		if (!szMyName)
-		{
-			continue;
-		}
-
 		// check whether our parent is known
 		// check whether our parent is known
 		bool bKnowParent = false;
 		bool bKnowParent = false;
 		for (unsigned int i2 = 0; i2 < pcScene->mNumMeshes;++i2)
 		for (unsigned int i2 = 0; i2 < pcScene->mNumMeshes;++i2)
@@ -388,10 +379,6 @@ void ASEImporter::BuildNodes()
 			const ASE::Mesh& mesh2 = *((const ASE::Mesh*)pcScene->mMeshes[i2]->mColors[2]);
 			const ASE::Mesh& mesh2 = *((const ASE::Mesh*)pcScene->mMeshes[i2]->mColors[2]);
 			// TODO: experimental quick'n'dirty, clean this up ...
 			// TODO: experimental quick'n'dirty, clean this up ...
 			std::string szMyName2[2] = {mesh2.mName,mesh2.mParent} ;
 			std::string szMyName2[2] = {mesh2.mName,mesh2.mParent} ;
-			if (!szMyName2)
-			{
-				continue;
-			}
 			if (!ASSIMP_stricmp ( szMyName[1], szMyName2[0]))
 			if (!ASSIMP_stricmp ( szMyName[1], szMyName2[0]))
 			{
 			{
 				bKnowParent = true;
 				bKnowParent = true;

+ 1 - 1
code/JoinVerticesProcess.cpp

@@ -248,7 +248,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
 		sprintf(szBuff,"Mesh %i | Verts in: %i out: %i | ~%.1f%%",
 		sprintf(szBuff,"Mesh %i | Verts in: %i out: %i | ~%.1f%%",
 			meshIndex,
 			meshIndex,
 			pMesh->mNumVertices,
 			pMesh->mNumVertices,
-			uniqueVertices.size(),
+			(int)uniqueVertices.size(),
 			((pMesh->mNumVertices - uniqueVertices.size()) / (float)pMesh->mNumVertices) * 100.f);
 			((pMesh->mNumVertices - uniqueVertices.size()) / (float)pMesh->mNumVertices) * 100.f);
 		DefaultLogger::get()->info(szBuff);
 		DefaultLogger::get()->info(szBuff);
 	}
 	}

+ 1 - 1
code/LWOBLoader.cpp

@@ -142,7 +142,7 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
 	while (cursor < end && max--)
 	while (cursor < end && max--)
 	{
 	{
 		LWO::Face& face = *it;++it;
 		LWO::Face& face = *it;++it;
-		if(face.mNumIndices = *cursor++)
+		if((face.mNumIndices = *cursor++))
 		{
 		{
 			if (cursor + face.mNumIndices >= end)break;
 			if (cursor + face.mNumIndices >= end)break;
 			face.mIndices = new unsigned int[face.mNumIndices];
 			face.mIndices = new unsigned int[face.mNumIndices];

+ 24 - 14
code/LWOLoader.cpp

@@ -174,14 +174,6 @@ void LWOImporter::InternReadFile( const std::string& pFile,
 	apcNodes.reserve(mLayers->size());
 	apcNodes.reserve(mLayers->size());
 	apcMeshes.reserve(mLayers->size()*std::min(((unsigned int)mSurfaces->size()/2u), 1u));
 	apcMeshes.reserve(mLayers->size()*std::min(((unsigned int)mSurfaces->size()/2u), 1u));
 
 
-	// the RemoveRedundantMaterials step will clean this up later
-	pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = (unsigned int)mSurfaces->size()];
-	for (unsigned int mat = 0; mat < pScene->mNumMaterials;++mat)
-	{
-		MaterialHelper* pcMat = new MaterialHelper();
-		pScene->mMaterials[mat] = pcMat;
-		ConvertMaterial((*mSurfaces)[mat],pcMat);
-	}
 
 
 	unsigned int iDefaultSurface = 0xffffffff; // index of the default surface
 	unsigned int iDefaultSurface = 0xffffffff; // index of the default surface
 	for (LayerList::const_iterator lit = mLayers->begin(), lend = mLayers->end();
 	for (LayerList::const_iterator lit = mLayers->begin(), lend = mLayers->end();
@@ -205,9 +197,9 @@ void LWOImporter::InternReadFile( const std::string& pFile,
 				if (idx >= mTags->size())
 				if (idx >= mTags->size())
 				{
 				{
 					DefaultLogger::get()->warn("LWO: Invalid face surface index");
 					DefaultLogger::get()->warn("LWO: Invalid face surface index");
-					idx = (unsigned int)mTags->size()-1;
+					idx = 0xffffffff;
 				}
 				}
-				if(0xffffffff == (idx = _mMapping[idx]))
+				if(0xffffffff == idx || 0xffffffff == (idx = _mMapping[idx]))
 				{
 				{
 					if (0xffffffff == iDefaultSurface)
 					if (0xffffffff == iDefaultSurface)
 					{
 					{
@@ -339,6 +331,16 @@ void LWOImporter::InternReadFile( const std::string& pFile,
 		for (unsigned int p = 0; p < pcNode->mNumMeshes;++p)
 		for (unsigned int p = 0; p < pcNode->mNumMeshes;++p)
 			pcNode->mMeshes[p] = p + meshStart;
 			pcNode->mMeshes[p] = p + meshStart;
 	}
 	}
+
+	// the RemoveRedundantMaterials step will clean this up later
+	pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = (unsigned int)mSurfaces->size()];
+	for (unsigned int mat = 0; mat < pScene->mNumMaterials;++mat)
+	{
+		MaterialHelper* pcMat = new MaterialHelper();
+		pScene->mMaterials[mat] = pcMat;
+		ConvertMaterial((*mSurfaces)[mat],pcMat);
+	}
+
 	// generate the final node graph
 	// generate the final node graph
 	GenerateNodeGraph(apcNodes);
 	GenerateNodeGraph(apcNodes);
 
 
@@ -360,6 +362,7 @@ void LWOImporter::GenerateNodeGraph(std::vector<aiNode*>& apcNodes)
 		aiNode* node;
 		aiNode* node;
 		uint16_t iCurParent = curIndex-1;
 		uint16_t iCurParent = curIndex-1;
 		node = curIndex ? apcNodes[iCurParent] : new aiNode("<dummy_root>");
 		node = curIndex ? apcNodes[iCurParent] : new aiNode("<dummy_root>");
+		if (!node){++curIndex;continue;}
 
 
 		unsigned int numChilds = 0;
 		unsigned int numChilds = 0;
 		for (unsigned int i = 0; i < apcNodes.size();++i)
 		for (unsigned int i = 0; i < apcNodes.size();++i)
@@ -385,6 +388,7 @@ void LWOImporter::GenerateNodeGraph(std::vector<aiNode*>& apcNodes)
 					apcNodes[i] = NULL;
 					apcNodes[i] = NULL;
 				}
 				}
 			}
 			}
+			if (curIndex)apcNodes[iCurParent] = NULL;
 		}
 		}
 		else if (!curIndex)delete node;
 		else if (!curIndex)delete node;
 		++curIndex;
 		++curIndex;
@@ -416,7 +420,11 @@ void LWOImporter::GenerateNodeGraph(std::vector<aiNode*>& apcNodes)
 			it != end;++it)
 			it != end;++it)
 		{
 		{
 			aiNode* p = *it;
 			aiNode* p = *it;
-			if (p)*cc++ = p;
+			if (p)
+			{
+				*cc++ = p;
+				p->mParent = pc;
+			}
 		}
 		}
 		if (pScene->mRootNode)
 		if (pScene->mRootNode)
 		{
 		{
@@ -544,6 +552,8 @@ void LWOImporter::LoadLWOPolygons(unsigned int length)
 	if (mIsLWO2)
 	if (mIsLWO2)
 	{
 	{
 		uint32_t type = *((LE_NCONST uint32_t*)mFileBuffer);mFileBuffer += 4;
 		uint32_t type = *((LE_NCONST uint32_t*)mFileBuffer);mFileBuffer += 4;
+		AI_LSWAP4(type);
+
 		if (type != AI_LWO_FACE)
 		if (type != AI_LWO_FACE)
 		{
 		{
 			DefaultLogger::get()->warn("LWO2: Only POLS.FACE chunsk are supported.");
 			DefaultLogger::get()->warn("LWO2: Only POLS.FACE chunsk are supported.");
@@ -601,7 +611,7 @@ void LWOImporter::CopyFaceIndicesLWO2(FaceList::iterator& it,
 	while (cursor < end && max--)
 	while (cursor < end && max--)
 	{
 	{
 		LWO::Face& face = *it;++it;
 		LWO::Face& face = *it;++it;
-		if(face.mNumIndices = (*cursor++) & 0x03FF)
+		if((face.mNumIndices = (*cursor++) & 0x03FF))
 		{
 		{
 			face.mIndices = new unsigned int[face.mNumIndices];
 			face.mIndices = new unsigned int[face.mNumIndices];
 			
 			
@@ -630,12 +640,12 @@ void LWOImporter::LoadLWO2PolygonTags(unsigned int length)
 		return;
 		return;
 
 
 	LE_NCONST uint8_t* const end = mFileBuffer+length;
 	LE_NCONST uint8_t* const end = mFileBuffer+length;
-	while (mFileBuffer < end)
+	while (mFileBuffer <= end)
 	{
 	{
 		unsigned int i = ReadVSizedIntLWO2(mFileBuffer) + mCurLayer->mFaceIDXOfs;
 		unsigned int i = ReadVSizedIntLWO2(mFileBuffer) + mCurLayer->mFaceIDXOfs;
 		unsigned int j = ReadVSizedIntLWO2(mFileBuffer);
 		unsigned int j = ReadVSizedIntLWO2(mFileBuffer);
 
 
-		if (i > mCurLayer->mFaces.size())
+		if (i >= mCurLayer->mFaces.size())
 		{
 		{
 			DefaultLogger::get()->warn("LWO2: face index in ptag list is out of range");
 			DefaultLogger::get()->warn("LWO2: face index in ptag list is out of range");
 			continue;
 			continue;

+ 2 - 1
code/LWOMaterial.cpp

@@ -173,9 +173,10 @@ void LWOImporter::LoadLWO2Surface(unsigned int size)
 	mFileBuffer+=surf.mName.length()+1;
 	mFileBuffer+=surf.mName.length()+1;
 	 // skip one byte if the length of the surface name is odd
 	 // skip one byte if the length of the surface name is odd
 	if (!(surf.mName.length() & 1))++mFileBuffer;
 	if (!(surf.mName.length() & 1))++mFileBuffer;
+	mFileBuffer += 2;
 	while (true)
 	while (true)
 	{
 	{
-		if (mFileBuffer + 6 > end)break;
+		if (mFileBuffer + 6 >= end)break;
 
 
 		// no proper IFF header here - the chunk length is specified as int16
 		// no proper IFF header here - the chunk length is specified as int16
 		uint32_t head_type		= *((LE_NCONST uint32_t*)mFileBuffer);mFileBuffer+=4;
 		uint32_t head_type		= *((LE_NCONST uint32_t*)mFileBuffer);mFileBuffer+=4;

+ 11 - 11
code/MD5Parser.cpp

@@ -91,19 +91,19 @@ MD5Parser::MD5Parser(char* buffer, unsigned int fileSize)
 	if ( !DefaultLogger::isNullLogger())
 	if ( !DefaultLogger::isNullLogger())
 	{
 	{
 		char szBuffer[128]; // should be sufficiently large
 		char szBuffer[128]; // should be sufficiently large
-		::sprintf(szBuffer,"MD5Parser end. Parsed %i sections",this->mSections.size());
+		::sprintf(szBuffer,"MD5Parser end. Parsed %i sections",(int)this->mSections.size());
 		DefaultLogger::get()->debug(szBuffer);
 		DefaultLogger::get()->debug(szBuffer);
 	}
 	}
 }
 }
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
-/*static*/ void MD5Parser::ReportError (char* error, unsigned int line)
+/*static*/ void MD5Parser::ReportError (const char* error, unsigned int line)
 {
 {
 	char szBuffer[1024]; // you, listen to me, you HAVE TO BE sufficiently large
 	char szBuffer[1024]; // you, listen to me, you HAVE TO BE sufficiently large
 	::sprintf(szBuffer,"Line %i: %s",line,error);
 	::sprintf(szBuffer,"Line %i: %s",line,error);
 	throw new ImportErrorException(szBuffer);
 	throw new ImportErrorException(szBuffer);
 }
 }
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
-/*static*/ void MD5Parser::ReportWarning (char* warn, unsigned int line)
+/*static*/ void MD5Parser::ReportWarning (const char* warn, unsigned int line)
 {
 {
 	char szBuffer[1024]; // you, listen to me, you HAVE TO BE sufficiently large
 	char szBuffer[1024]; // you, listen to me, you HAVE TO BE sufficiently large
 	::sprintf(szBuffer,"Line %i: %s",line,warn);
 	::sprintf(szBuffer,"Line %i: %s",line,warn);
@@ -248,7 +248,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
 			if ( !::strcmp("numMeshes",(*iter).mName.c_str()))
 			if ( !::strcmp("numMeshes",(*iter).mName.c_str()))
 			{
 			{
 				unsigned int iNumMeshes;
 				unsigned int iNumMeshes;
-				if(iNumMeshes = ::strtol10((*iter).mGlobalValue.c_str()))
+				if((iNumMeshes = ::strtol10((*iter).mGlobalValue.c_str())))
 				{
 				{
 					mMeshes.reserve(iNumMeshes);
 					mMeshes.reserve(iNumMeshes);
 				}
 				}
@@ -256,7 +256,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
 			else if ( !::strcmp("numJoints",(*iter).mName.c_str()))
 			else if ( !::strcmp("numJoints",(*iter).mName.c_str()))
 			{
 			{
 				unsigned int iNumJoints;
 				unsigned int iNumJoints;
-				if(iNumJoints = ::strtol10((*iter).mGlobalValue.c_str()))
+				if((iNumJoints = ::strtol10((*iter).mGlobalValue.c_str())))
 				{
 				{
 					mJoints.reserve(iNumJoints);
 					mJoints.reserve(iNumJoints);
 				}
 				}
@@ -316,7 +316,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
 					// reserve enough storage
 					// reserve enough storage
 					AI_MD5_SKIP_SPACES();
 					AI_MD5_SKIP_SPACES();
 					unsigned int iNumVertices;
 					unsigned int iNumVertices;
-					if(iNumVertices = ::strtol10(sz))
+					if((iNumVertices = ::strtol10(sz)))
 						desc.mVertices.resize(iNumVertices);
 						desc.mVertices.resize(iNumVertices);
 				}
 				}
 				// numtris attribute
 				// numtris attribute
@@ -326,7 +326,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
 					// reserve enough storage
 					// reserve enough storage
 					AI_MD5_SKIP_SPACES();
 					AI_MD5_SKIP_SPACES();
 					unsigned int iNumTris;
 					unsigned int iNumTris;
-					if(iNumTris = ::strtol10(sz))
+					if((iNumTris = ::strtol10(sz)))
 						desc.mFaces.resize(iNumTris);
 						desc.mFaces.resize(iNumTris);
 				}
 				}
 				// numweights attribute
 				// numweights attribute
@@ -336,7 +336,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
 					// reserve enough storage
 					// reserve enough storage
 					AI_MD5_SKIP_SPACES();
 					AI_MD5_SKIP_SPACES();
 					unsigned int iNumWeights;
 					unsigned int iNumWeights;
-					if(iNumWeights = ::strtol10(sz))
+					if((iNumWeights = ::strtol10(sz)))
 						desc.mWeights.resize(iNumWeights);
 						desc.mWeights.resize(iNumWeights);
 				}
 				}
 				// vert attribute
 				// vert attribute
@@ -507,7 +507,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
 		else if(!::strcmp("numFrames",(*iter).mName.c_str()))
 		else if(!::strcmp("numFrames",(*iter).mName.c_str()))
 		{
 		{
 			unsigned int iNum;
 			unsigned int iNum;
-			if(iNum = ::strtol10((*iter).mGlobalValue.c_str()))
+			if((iNum = ::strtol10((*iter).mGlobalValue.c_str())))
 			{
 			{
 				mFrames.reserve(iNum);
 				mFrames.reserve(iNum);
 			}
 			}
@@ -515,7 +515,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
 		else if(!::strcmp("numJoints",(*iter).mName.c_str()))
 		else if(!::strcmp("numJoints",(*iter).mName.c_str()))
 		{
 		{
 			unsigned int iNum;
 			unsigned int iNum;
-			if(iNum = ::strtol10((*iter).mGlobalValue.c_str()))
+			if((iNum = ::strtol10((*iter).mGlobalValue.c_str())))
 			{
 			{
 				mAnimatedBones.reserve(iNum);
 				mAnimatedBones.reserve(iNum);
 
 
@@ -527,7 +527,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
 		else if(!::strcmp("numAnimatedComponents",(*iter).mName.c_str()))
 		else if(!::strcmp("numAnimatedComponents",(*iter).mName.c_str()))
 		{
 		{
 			unsigned int iNum;
 			unsigned int iNum;
-			if(iNum = ::strtol10((*iter).mGlobalValue.c_str()))
+			if((iNum = ::strtol10((*iter).mGlobalValue.c_str())))
 			{
 			{
 				mAnimatedBones.reserve(iNum);
 				mAnimatedBones.reserve(iNum);
 			}
 			}

+ 4 - 4
code/MD5Parser.h

@@ -325,20 +325,20 @@ public:
 	 *  @param error Error message to be reported
 	 *  @param error Error message to be reported
 	 *  @param line Index of the line where the error occured
 	 *  @param line Index of the line where the error occured
 	 */
 	 */
-	static void ReportError (char* error, unsigned int line);
+	static void ReportError (const char* error, unsigned int line);
 
 
 	// -------------------------------------------------------------------
 	// -------------------------------------------------------------------
 	/** Report a specific warning
 	/** Report a specific warning
 	 *  @param warn Warn message to be reported
 	 *  @param warn Warn message to be reported
 	 *  @param line Index of the line where the error occured
 	 *  @param line Index of the line where the error occured
 	 */
 	 */
-	static void ReportWarning (char* warn, unsigned int line);
+	static void ReportWarning (const char* warn, unsigned int line);
 
 
 
 
-	inline void ReportError (char* error)
+	inline void ReportError (const char* error)
 		{return ReportError(error, this->lineNumber);}
 		{return ReportError(error, this->lineNumber);}
 
 
-	inline void ReportWarning (char* warn)
+	inline void ReportWarning (const char* warn)
 		{return ReportWarning(warn, this->lineNumber);}
 		{return ReportWarning(warn, this->lineNumber);}
 
 
 
 

+ 1 - 1
code/STLLoader.cpp

@@ -179,7 +179,7 @@ void STLImporter::LoadASCIIFile()
 	unsigned int temp;
 	unsigned int temp;
 
 
 	// setup the name of the node
 	// setup the name of the node
-	if (temp = (unsigned int)(sz-szMe))
+	if ((temp = (unsigned int)(sz-szMe)))
 	{
 	{
 		pScene->mRootNode->mName.length = temp;
 		pScene->mRootNode->mName.length = temp;
 		::memcpy(pScene->mRootNode->mName.data,szMe,temp);
 		::memcpy(pScene->mRootNode->mName.data,szMe,temp);

+ 1 - 1
code/SplitLargeMeshes.cpp

@@ -591,7 +591,7 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh(
 				{
 				{
 					// check whether the bone is existing
 					// check whether the bone is existing
 					BoneWeightList* pcWeightList;
 					BoneWeightList* pcWeightList;
-					if (pcWeightList = (BoneWeightList*)pcMesh->mBones[k])
+					if ((pcWeightList = (BoneWeightList*)pcMesh->mBones[k]))
 					{
 					{
 						aiBone* pcOldBone = pMesh->mBones[k];
 						aiBone* pcOldBone = pMesh->mBones[k];
 						aiBone* pcOut;
 						aiBone* pcOut;

+ 3 - 3
code/TextureTransform.cpp

@@ -60,7 +60,7 @@ void TextureTransform::PreProcessUVTransform(
 
 
 	if (rcIn.mOffsetU)
 	if (rcIn.mOffsetU)
 	{
 	{
-		if (iField = (int)rcIn.mOffsetU)
+		if ((iField = (int)rcIn.mOffsetU))
 		{
 		{
 			if (aiTextureMapMode_Wrap == rcIn.mMapMode)
 			if (aiTextureMapMode_Wrap == rcIn.mMapMode)
 			{
 			{
@@ -94,7 +94,7 @@ void TextureTransform::PreProcessUVTransform(
 	}
 	}
 	if (rcIn.mOffsetV)
 	if (rcIn.mOffsetV)
 	{
 	{
-		if (iField = (int)rcIn.mOffsetV)
+		if ((iField = (int)rcIn.mOffsetV))
 		{
 		{
 			if (aiTextureMapMode_Wrap == rcIn.mMapMode)
 			if (aiTextureMapMode_Wrap == rcIn.mMapMode)
 			{
 			{
@@ -128,7 +128,7 @@ void TextureTransform::PreProcessUVTransform(
 	}
 	}
 	if (rcIn.mRotation)
 	if (rcIn.mRotation)
 	{
 	{
-		if (iField = (int)(rcIn.mRotation / 3.141592654f))
+		if ((iField = (int)(rcIn.mRotation / 3.141592654f)))
 		{
 		{
 			float fNew = rcIn.mRotation-(float)iField*3.141592654f;
 			float fNew = rcIn.mRotation-(float)iField*3.141592654f;