diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 12cc24797..a5dcab19b 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -404,6 +404,10 @@ void ColladaParser::PostProcessControllers() { std::string meshId; for (ControllerLibrary::iterator it = mControllerLibrary.begin(); it != mControllerLibrary.end(); ++it) { meshId = it->second.mMeshId; + if (meshId.empty()) { + break; + } + ControllerLibrary::iterator findItr = mControllerLibrary.find(meshId); while (findItr != mControllerLibrary.end()) { meshId = findItr->second.mMeshId; @@ -1404,6 +1408,7 @@ void ColladaParser::ReadDataArray(XmlNode &node) { XmlParser::getUIntAttribute(node, "count", count); std::string v; XmlParser::getValueAsString(node, v); + trim(v); const char *content = v.c_str(); // read values and store inside an array in the data library @@ -1437,6 +1442,7 @@ void ColladaParser::ReadDataArray(XmlNode &node) { ai_real value; // read a number + //SkipSpacesAndLineEnd(&content); content = fast_atoreal_move(content, value); data.mValues.push_back(value); // skip whitespace after it diff --git a/include/assimp/StringUtils.h b/include/assimp/StringUtils.h index 7e1cb4ce0..545a9ff30 100644 --- a/include/assimp/StringUtils.h +++ b/include/assimp/StringUtils.h @@ -52,6 +52,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include +#include +#include /// @fn ai_snprintf /// @brief The portable version of the function snprintf ( C99 standard ), which works on visual studio compilers 2013 and earlier. @@ -162,4 +165,22 @@ AI_FORCE_INLINE std::string Rgba2Hex(int r, int g, int b, int a, bool with_head) return ss.str(); } +inline void ltrim(std::string &s) { + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { + return !std::isspace(ch); + })); +} + +// trim from end (in place) +inline void rtrim(std::string &s) { + s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { + return !std::isspace(ch); + }).base(), s.end()); +} + +// trim from both ends (in place) +inline void trim(std::string &s) { + ltrim(s); + rtrim(s); +} #endif // INCLUDED_AI_STRINGUTILS_H diff --git a/test/unit/utColladaExport.cpp b/test/unit/utColladaExport.cpp index efb2d7f17..56b24798e 100644 --- a/test/unit/utColladaExport.cpp +++ b/test/unit/utColladaExport.cpp @@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include + #ifndef ASSIMP_BUILD_NO_EXPORT class utColladaExport : public ::testing::Test { @@ -77,6 +79,7 @@ TEST_F(utColladaExport, testExportCamera) { EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file)); const unsigned int origNumCams(pTest->mNumCameras); + //std::vector origFOV; std::unique_ptr origFOV(new float[origNumCams]); std::unique_ptr orifClipPlaneNear(new float[origNumCams]); std::unique_ptr orifClipPlaneFar(new float[origNumCams]);