From 3d2cb1cabf61ee0020e1168ec8288e8079b9e64c Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 14 Mar 2017 10:40:27 -0700 Subject: [PATCH] also allow absolute path in asset files (.obj, .stl, .dae etc) --- .../ImportURDFDemo/BulletUrdfImporter.cpp | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp index 0820d7e5e..ae3364334 100644 --- a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp +++ b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp @@ -512,19 +512,32 @@ bool findExistingMeshFile( shorter.reverse(); std::string existing_file; - for (std::list::iterator x=shorter.begin(); x!=shorter.end(); ++x) + { - std::string attempt = *x + "/" + fn; + std::string attempt = fn; FILE* f = fopen(attempt.c_str(), "rb"); - if (!f) + if (f) { - //b3Printf("%s: tried '%s'", error_message_prefix.c_str(), attempt.c_str()); - continue; + existing_file = attempt; + fclose(f); + } + } + if (existing_file.empty()) + { + for (std::list::iterator x=shorter.begin(); x!=shorter.end(); ++x) + { + std::string attempt = *x + "/" + fn; + FILE* f = fopen(attempt.c_str(), "rb"); + if (!f) + { + //b3Printf("%s: tried '%s'", error_message_prefix.c_str(), attempt.c_str()); + continue; + } + fclose(f); + existing_file = attempt; + //b3Printf("%s: found '%s'", error_message_prefix.c_str(), attempt.c_str()); + break; } - fclose(f); - existing_file = attempt; - //b3Printf("%s: found '%s'", error_message_prefix.c_str(), attempt.c_str()); - break; } if (existing_file.empty())