Преглед изворни кода

Bugfix : Removed some unnecessary const_casts. ( merged from GitHub, thanks to Riku Palomäki ).

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1223 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
kimmi пре 13 година
родитељ
комит
d17071746d
4 измењених фајлова са 7 додато и 7 уклоњено
  1. 1 1
      code/BaseImporter.cpp
  2. 2 2
      code/ColladaLoader.cpp
  3. 1 1
      code/IFCLoader.cpp
  4. 3 3
      code/MDLMaterialLoader.cpp

+ 1 - 1
code/BaseImporter.cpp

@@ -525,7 +525,7 @@ void BatchLoader::LoadAll()
 			DefaultLogger::get()->info("File: " + (*it).file);
 			DefaultLogger::get()->info("File: " + (*it).file);
 		}
 		}
 		data->pImporter->ReadFile((*it).file,pp);
 		data->pImporter->ReadFile((*it).file,pp);
-		(*it).scene = const_cast<aiScene*>(data->pImporter->GetOrphanedScene());
+		(*it).scene = data->pImporter->GetOrphanedScene();
 		(*it).loaded = true;
 		(*it).loaded = true;
 
 
 		DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%");
 		DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%");

+ 2 - 2
code/ColladaLoader.cpp

@@ -230,13 +230,13 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co
 	{
 	{
 		// find the corresponding node in the library
 		// find the corresponding node in the library
 		const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find((*it).mNode);
 		const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find((*it).mNode);
-		Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second;
+		const Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second;
 
 
 		// FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632
 		// FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632
 		// need to check for both name and ID to catch all. To avoid breaking valid files,
 		// need to check for both name and ID to catch all. To avoid breaking valid files,
 		// the workaround is only enabled when the first attempt to resolve the node has failed.
 		// the workaround is only enabled when the first attempt to resolve the node has failed.
 		if (!nd) {
 		if (!nd) {
-			nd = const_cast<Collada::Node*>(FindNode(pParser.mRootNode,(*it).mNode));
+			nd = FindNode(pParser.mRootNode,(*it).mNode);
 		}
 		}
 		if (!nd) 
 		if (!nd) 
 			DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + (*it).mNode);
 			DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + (*it).mNode);

+ 1 - 1
code/IFCLoader.cpp

@@ -155,7 +155,7 @@ void IFCImporter::InternReadFile( const std::string& pFile,
 	}
 	}
 
 
 	boost::scoped_ptr<STEP::DB> db(STEP::ReadFileHeader(stream));
 	boost::scoped_ptr<STEP::DB> db(STEP::ReadFileHeader(stream));
-	const STEP::HeaderInfo& head = const_cast<const STEP::DB&>(*db).GetHeader();
+	const STEP::HeaderInfo& head = static_cast<const STEP::DB&>(*db).GetHeader();
 
 
 	if(!head.fileSchema.size() || head.fileSchema.substr(0,3) != "IFC") {
 	if(!head.fileSchema.size() || head.fileSchema.substr(0,3) != "IFC") {
 		ThrowException("Unrecognized file schema: " + head.fileSchema);
 		ThrowException("Unrecognized file schema: " + head.fileSchema);

+ 3 - 3
code/MDLMaterialLoader.cpp

@@ -63,9 +63,9 @@ void MDLImporter::SearchPalette(const unsigned char** pszColorMap)
 	{
 	{
 		if (pcStream->FileSize() >= 768)
 		if (pcStream->FileSize() >= 768)
 		{
 		{
-			szColorMap = new unsigned char[256*3];
-			pcStream->Read(const_cast<unsigned char*>(szColorMap),256*3,1);
-
+			unsigned char* colorMap = new unsigned char[256*3];
+			szColorMap = colorMap;
+			pcStream->Read(colorMap,256*3,1);
 			DefaultLogger::get()->info("Found valid colormap.lmp in directory. "
 			DefaultLogger::get()->info("Found valid colormap.lmp in directory. "
 				"It will be used to decode embedded textures in palletized formats.");
 				"It will be used to decode embedded textures in palletized formats.");
 		}
 		}