Repository: zeux/meshoptimizer (language: cpp)

Issue:
Decimal separator issue in gltf pack
We have integrated the gltf pack to optimize the gltf file for compression and quantization.
We have observed that we are facing the issue when we change the decimal separator of the machine to comma(,) the gltf file is not handling the numeric localization.
Adding in debug mode we are able to get the proper output of GLTF file but in case of release mode we are facing issue.

componentType":5126,"count":853,"type":"VEC3",
"min":[-7,80547619,-5,77579021,-0,248065487],// here the comma(,) is observed insteaded of dot(.)
"max":[10,199213,5,72420979,21,3658981]}// here the comma(,) is observed insteaded of dot(.)

Looking forward to hear from you.
Thanks & Regards,


Discussion / hints:
Just to double check, this is with the native build? Is the platform Linux? This can probably be fixed by doing `    setlocale(LC_ALL, "C");` in `main()` before any other code runs.

Fix patch:
diff --git a/gltf/gltfpack.cpp b/gltf/gltfpack.cpp
index 611d259cf..f149af7e2 100644
--- a/gltf/gltfpack.cpp
+++ b/gltf/gltfpack.cpp
@@ -3,6 +3,7 @@
 
 #include <algorithm>
 
+#include <locale.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -1144,6 +1145,10 @@ unsigned int textureMask(const char* arg)
 
 int main(int argc, char** argv)
 {
+#ifndef __wasi__
+	setlocale(LC_ALL, "C"); // disable locale specific convention for number parsing/printing
+#endif
+
 	meshopt_encodeIndexVersion(1);
 
 	Settings settings = defaults();


Test patch: