Sfoglia il codice sorgente

Apply patch [3473792] - LWS loader failed to find LWO files referenced with inaccessible, absolute paths, but actually residing in the folder of the LWS file. Applied the patch to FileSystemFilter, so all loaders do this now.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1113 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg 13 anni fa
parent
commit
81ef6af2df
2 ha cambiato i file con 25 aggiunte e 5 eliminazioni
  1. 20 3
      code/FileSystemFilter.h
  2. 5 2
      code/LWSLoader.cpp

+ 20 - 3
code/FileSystemFilter.h

@@ -172,7 +172,7 @@ private:
 	void BuildPath (std::string& in) const
 	void BuildPath (std::string& in) const
 	{
 	{
 		// if we can already access the file, great.
 		// if we can already access the file, great.
-		if (in.length() < 3 || wrapped->Exists(in.c_str())) {
+		if (in.length() < 3 || wrapped->Exists(in)) {
 			return;
 			return;
 		}
 		}
 
 
@@ -180,8 +180,25 @@ private:
 		if (in[1] != ':') {
 		if (in[1] != ':') {
 		
 		
 			// append base path and try 
 			// append base path and try 
-			in = base + in;
-			if (wrapped->Exists(in.c_str())) {
+			const std::string tmp = base + in;
+			if (wrapped->Exists(tmp)) {
+				in = tmp;
+				return;
+			}
+		}
+		
+		// Chop of the file name and look in the current directory
+		size_t pos = in.rfind("/");
+		if (std::string::npos == pos) {
+			pos = in.rfind("\\");
+		}
+
+		if (std::string::npos != pos)	{
+			std::string tmp = ".";
+			tmp += wrapped->getOsSeparator();
+			tmp += in.substr(pos+1, in.length()-pos); 
+			if (wrapped->Exists(tmp)) {
+				in = tmp;
 				return;
 				return;
 			}
 			}
 		}
 		}

+ 5 - 2
code/LWSLoader.cpp

@@ -452,8 +452,9 @@ std::string LWSImporter::FindLWOFile(const std::string& in)
 	}
 	}
 	else tmp = in;
 	else tmp = in;
 
 
-	if (io->Exists(tmp))
+	if (io->Exists(tmp)) {
 		return in;
 		return in;
+	}
 
 
 	// file is not accessible for us ... maybe it's packed by 
 	// file is not accessible for us ... maybe it's packed by 
 	// LightWave's 'Package Scene' command?
 	// LightWave's 'Package Scene' command?
@@ -468,8 +469,10 @@ std::string LWSImporter::FindLWOFile(const std::string& in)
 		return test;
 		return test;
 
 
 	test = ".." + io->getOsSeparator() + test; 
 	test = ".." + io->getOsSeparator() + test; 
-	if (io->Exists(test))
+	if (io->Exists(test)) {
 		return test;
 		return test;
+	}
+
 
 
 	// return original path, maybe the IOsystem knows better
 	// return original path, maybe the IOsystem knows better
 	return tmp;
 	return tmp;