Skip to content

Commit

Permalink
Merge pull request #978 from overte-org/fix/gltf_locale
Browse files Browse the repository at this point in the history
Fixed locale problems with cgltf.h
  • Loading branch information
ksuprynowicz authored May 23, 2024
2 parents bb8bac4 + 1ba6026 commit 13a7ea3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion libraries/model-serializers/src/GLTFSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,29 @@
#ifndef hifi_GLTFSerializer_h
#define hifi_GLTFSerializer_h

#include "cgltf.h"
#include <sstream>

#include <memory.h>
#include <QtNetwork/QNetworkReply>
#include <hfm/ModelFormatLogging.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 {
Q_OBJECT
Expand Down

0 comments on commit 13a7ea3

Please sign in to comment.