aboutsummaryrefslogtreecommitdiffstats
path: root/service/src
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2021-05-23 19:00:18 +0200
committerLouis Burda <quent.burda@gmail.com>2021-05-23 19:00:18 +0200
commitddf5c236446767b60718b7254a4e4d3c5e4c941c (patch)
tree92a5d4aa322547c54dc5f06d5a78b2a8bb765695 /service/src
parentf75abdd928302e8ef555e1f10b19b6105609775e (diff)
downloadenowars5-service-stldoctor-ddf5c236446767b60718b7254a4e4d3c5e4c941c.tar.gz
enowars5-service-stldoctor-ddf5c236446767b60718b7254a4e4d3c5e4c941c.zip
added test command for upload custom file, various smaller changes, fixed float little-endian loading
Diffstat (limited to 'service/src')
-rw-r--r--service/src/stlfile.c14
-rw-r--r--service/src/util.h2
2 files changed, 15 insertions, 1 deletions
diff --git a/service/src/stlfile.c b/service/src/stlfile.c
index 4dda8ee..88fc430 100644
--- a/service/src/stlfile.c
+++ b/service/src/stlfile.c
@@ -248,7 +248,7 @@ parse_file_bin(struct parseinfo *info, char *buf, size_t len)
bp += 12;
for (k = 0; k < 3; k++, bp += 12) {
for (m = 0; m < 3; m++) {
- v = le32toh(*(float *)(bp + 4 * m));
+ v = fle32toh(*(float*)(bp + 4 * m));
info->bbmin[m] = MIN(info->bbmin[m], v);
info->bbmax[m] = MAX(info->bbmax[m], v);
}
@@ -401,3 +401,15 @@ free_info(struct parseinfo *info)
NULLFREE(info->solidname);
info->valid = 0;
}
+
+float fle32toh(float v)
+{
+ union {
+ uint32_t u;
+ float f;
+ } conv;
+
+ conv.f = v;
+ conv.u = le32toh(conv.u);
+ return conv.f;
+}
diff --git a/service/src/util.h b/service/src/util.h
index eaef14f..c0e9064 100644
--- a/service/src/util.h
+++ b/service/src/util.h
@@ -31,6 +31,8 @@ const char* ask(const char *fmtstr, ...);
void dump(const char *filepath);
int strpfcmp(const char *prefix, const char *str);
+float fle32toh(float v);
+
extern int echo;
#endif /* UTIL_H */