backport of
https://github.com/bulletphysics/bullet3/commit/4f0673810cab0eee67ea314a3243952afd150cb4

Index: examples/DeformableDemo/LoadDeformed.cpp
--- examples/DeformableDemo/LoadDeformed.cpp.orig
+++ examples/DeformableDemo/LoadDeformed.cpp
@@ -26,7 +26,151 @@
 #include "../CommonInterfaces/CommonDeformableBodyBase.h"
 #include "../Utils/b3ResourcePath.h"
 #include "../Utils/b3BulletDefaultFileIO.h"
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <string.h>
 
+struct CustomSoftBodyHelper : public btSoftBodyHelpers
+{
+	static std::string loadDeformableState(btAlignedObjectArray<btVector3>& qs, btAlignedObjectArray<btVector3>& vs, const char* filename, CommonFileIOInterface* fileIO);
+	
+};
+
+static inline bool isSpace(const char c)
+{
+	return (c == ' ') || (c == '\t');
+}
+static inline bool isNewLine(const char c)
+{
+	return (c == '\r') || (c == '\n') || (c == '\0');
+}
+static inline float parseFloat(const char*& token)
+{
+	token += strspn(token, " \t");
+	float f = (float)atof(token);
+	token += strcspn(token, " \t\r");
+	return f;
+}
+static inline void parseFloat3(
+	float& x, float& y, float& z,
+	const char*& token)
+{
+	x = parseFloat(token);
+	y = parseFloat(token);
+	z = parseFloat(token);
+}
+
+
+std::string CustomSoftBodyHelper::loadDeformableState(btAlignedObjectArray<btVector3>& qs, btAlignedObjectArray<btVector3>& vs, const char* filename, CommonFileIOInterface* fileIO)
+{
+	{
+		qs.clear();
+		vs.clear();
+		std::string tmp = filename;
+		std::stringstream err;
+#ifdef USE_STREAM
+		std::ifstream ifs(filename);
+		if (!ifs)
+		{
+			err << "Cannot open file [" << filename << "]" << std::endl;
+			return err.str();
+		}
+#else
+		int fileHandle = fileIO->fileOpen(filename, "r");
+		if (fileHandle < 0)
+		{
+			err << "Cannot open file [" << filename << "]" << std::endl;
+			return err.str();
+		}
+#endif
+
+		std::string name;
+
+		int maxchars = 8192;              // Alloc enough size.
+		std::vector<char> buf(maxchars);  // Alloc enough size.
+		std::string linebuf;
+		linebuf.reserve(maxchars);
+
+#ifdef USE_STREAM
+		while (ifs.peek() != -1)
+#else
+		char* line = 0;
+		do
+#endif
+		{
+			linebuf.resize(0);
+#ifdef USE_STREAM
+			safeGetline(ifs, linebuf);
+#else
+			char tmpBuf[1024];
+			line = fileIO->readLine(fileHandle, tmpBuf, 1024);
+			if (line)
+			{
+				linebuf = line;
+			}
+#endif
+			// Trim newline '\r\n' or '\r'
+			if (linebuf.size() > 0)
+			{
+				if (linebuf[linebuf.size() - 1] == '\n') linebuf.erase(linebuf.size() - 1);
+			}
+			if (linebuf.size() > 0)
+			{
+				if (linebuf[linebuf.size() - 1] == '\n') linebuf.erase(linebuf.size() - 1);
+			}
+
+			// Skip if empty line.
+			if (linebuf.empty())
+			{
+				continue;
+			}
+
+			// Skip leading space.
+			const char* token = linebuf.c_str();
+			token += strspn(token, " \t");
+
+			btAssert(token);
+			if (token[0] == '\0') continue;  // empty line
+
+			if (token[0] == '#') continue;  // comment line
+
+			// q
+			if (token[0] == 'q' && isSpace((token[1])))
+			{
+				token += 2;
+				float x, y, z;
+				parseFloat3(x, y, z, token);
+				qs.push_back(btVector3(x, y, z));
+				continue;
+			}
+
+			// v
+			if (token[0] == 'v' && isSpace((token[1])))
+			{
+				token += 3;
+				float x, y, z;
+				parseFloat3(x, y, z, token);
+				vs.push_back(btVector3(x, y, z));
+				continue;
+			}
+
+			// Ignore unknown command.
+		}
+#ifndef USE_STREAM
+		while (line)
+			;
+#endif
+
+		if (fileHandle >= 0)
+		{
+			fileIO->fileClose(fileHandle);
+		}
+		return err.str();
+	}
+}
+
+
 class LoadDeformed : public CommonDeformableBodyBase
 {
 	int steps;
@@ -188,7 +332,7 @@ void LoadDeformed::addCloth(const btVector3& origin)
 	fileio.findResourcePath(filename, absolute_path, 1024);
 	btAlignedObjectArray<btVector3> qs;
 	btAlignedObjectArray<btVector3> vs;
-	btSoftBodyHelpers::loadDeformableState(qs, vs, absolute_path, &fileio);
+	CustomSoftBodyHelper::loadDeformableState(qs, vs, absolute_path, &fileio);
 	if (reset_frame > 0)
 		psb->updateState(qs, vs);
 	psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
