Skip to content

Commit

Permalink
Fix string to float conversion for systems using anything other than …
Browse files Browse the repository at this point in the history
…a period as decimal separator
  • Loading branch information
JulianGro committed Aug 21, 2022
1 parent cc69f9c commit 538a80c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/model-serializers/src/OBJSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Created by Seth Alves on 3/7/15.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2022 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Expand Down Expand Up @@ -59,7 +60,11 @@ const hifi::ByteArray OBJTokenizer::getLineAsDatum() {
}

float OBJTokenizer::getFloat() {
return std::stof((nextToken() != OBJTokenizer::DATUM_TOKEN) ? nullptr : getDatum().data());
std::istringstream ss((nextToken() != OBJTokenizer::DATUM_TOKEN) ? nullptr : getDatum().data());
ss.imbue(std::locale::classic());
float f;
ss >> f;
return f;
}

int OBJTokenizer::nextToken(bool allowSpaceChar /*= false*/) {
Expand Down

0 comments on commit 538a80c

Please sign in to comment.