summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Xu <pengxu@google.com>2020-08-11 01:48:55 -0700
committerPeng Xu <pengxu@google.com>2020-08-11 01:48:55 -0700
commitfc676c02c99c84a18d34592c88101458474babfe (patch)
tree3e5fec41f472c522a3669c3aaa095e7128cec4f3
parent714e25e8a78f22bcd9524c86110bf8f9a7f4a4cd (diff)
downloadbullet3-fc676c02c99c84a18d34592c88101458474babfe.tar.gz
Simplify logic for searching files in UrdfFindMeshFile and prioritize path without prefix.
-rw-r--r--examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h41
1 files changed, 14 insertions, 27 deletions
diff --git a/examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h b/examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h
index 147d8c911..3050cadde 100644
--- a/examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h
+++ b/examples/Importers/ImportURDFDemo/UrdfFindMeshFile.h
@@ -63,48 +63,35 @@ static bool UrdfFindMeshFile(
fn = fn.substr(drop_it_model.length());
std::list<std::string> shorter;
- shorter.push_back("../..");
- shorter.push_back("..");
- shorter.push_back(".");
+ shorter.push_back("../../");
+ shorter.push_back("../");
+ shorter.push_back("./");
int cnt = urdf_path.size();
for (int i = 0; i < cnt; ++i)
{
if (urdf_path[i] == '/' || urdf_path[i] == '\\')
{
- shorter.push_back(urdf_path.substr(0, i));
+ shorter.push_back(urdf_path.substr(0, i) + "/");
}
}
+ shorter.push_back(""); // no prefix
shorter.reverse();
std::string existing_file;
-
-
+ for (std::list<std::string>::iterator x = shorter.begin(); x != shorter.end(); ++x)
{
- for (std::list<std::string>::iterator x = shorter.begin(); x != shorter.end(); ++x)
- {
- std::string attempt = *x + "/" + fn;
- int f = fileIO->fileOpen(attempt.c_str(), "rb");
- if (f<0)
- {
- //b3Printf("%s: tried '%s'", error_message_prefix.c_str(), attempt.c_str());
- continue;
- }
- fileIO->fileClose(f);
- existing_file = attempt;
- //b3Printf("%s: found '%s'", error_message_prefix.c_str(), attempt.c_str());
- break;
- }
- }
- if (existing_file.empty())
- {
- std::string attempt = fn;
+ std::string attempt = *x + fn;
int f = fileIO->fileOpen(attempt.c_str(), "rb");
- if (f>=0)
+ if (f<0)
{
- existing_file = attempt;
- fileIO->fileClose(f);
+ //b3Printf("%s: tried '%s'", error_message_prefix.c_str(), attempt.c_str());
+ continue;
}
+ fileIO->fileClose(f);
+ existing_file = attempt;
+ //b3Printf("%s: found '%s'", error_message_prefix.c_str(), attempt.c_str());
+ break;
}
if (existing_file.empty())