mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 13:04:07 +02:00
Merge pull request #978 from overte-org/fix/gltf_locale
Fixed locale problems with cgltf.h
This commit is contained in:
commit
13a7ea356a
1 changed files with 17 additions and 1 deletions
|
@ -14,13 +14,29 @@
|
||||||
#ifndef hifi_GLTFSerializer_h
|
#ifndef hifi_GLTFSerializer_h
|
||||||
#define hifi_GLTFSerializer_h
|
#define hifi_GLTFSerializer_h
|
||||||
|
|
||||||
#include "cgltf.h"
|
#include <sstream>
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
#include <hfm/ModelFormatLogging.h>
|
#include <hfm/ModelFormatLogging.h>
|
||||||
#include <hfm/HFMSerializer.h>
|
#include <hfm/HFMSerializer.h>
|
||||||
|
|
||||||
|
static float atof_locale_independent(char *str) {
|
||||||
|
//TODO: Once we have C++17 we can use std::from_chars
|
||||||
|
std::istringstream streamToParse(str);
|
||||||
|
streamToParse.imbue(std::locale("C"));
|
||||||
|
float value;
|
||||||
|
if(!(streamToParse >> value)) {
|
||||||
|
qDebug(modelformat) << "cgltf: Cannot parse float from string: " << str;
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CGLTF_ATOF(str) atof_locale_independent(str)
|
||||||
|
|
||||||
|
#include "cgltf.h"
|
||||||
|
|
||||||
|
|
||||||
class GLTFSerializer : public QObject, public HFMSerializer {
|
class GLTFSerializer : public QObject, public HFMSerializer {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Reference in a new issue