summaryrefslogtreecommitdiff
path: root/meme/stl.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-12 15:48:34 (GMT)
committerWerner Almesberger <werner@almesberger.net>2014-09-12 15:48:34 (GMT)
commit1828a5a3c2391dbb9892f599dec669b140682246 (patch)
tree0c5976fcfab35089ecda515dc788fe3c06c46b4b /meme/stl.c
parent147d9e79b009a86e03ec15c8ba5e34961ffa9cb5 (diff)
downloadmisc-1828a5a3c2391dbb9892f599dec669b140682246.zip
misc-1828a5a3c2391dbb9892f599dec669b140682246.tar.gz
misc-1828a5a3c2391dbb9892f599dec669b140682246.tar.bz2
meme/stl.c (stl_load): use single precision for coordinates
This reduces one mesh load time from about 16.9 s to 15.7 s. Kinda surprising - I thought using "double" didn't have much of a performance impact these days.
Diffstat (limited to 'meme/stl.c')
-rw-r--r--meme/stl.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/meme/stl.c b/meme/stl.c
index 5409558..084cac5 100644
--- a/meme/stl.c
+++ b/meme/stl.c
@@ -43,7 +43,7 @@ void stl_load(FILE *file)
char *s, *e;
int n = 0;
int end, got;
- double x, y, z;
+ float x, y, z;
mesh_init();
while (fgets(buf, sizeof(buf), file)) {
@@ -75,12 +75,11 @@ void stl_load(FILE *file)
num_v = 0;
break;
case s_vertices:
- got = sscanf(s, "vertex %lf %lf %lf%n",
- &x,&y, &z, &end);
+ got = sscanf(s, "vertex %f %f %f%n", &x,&y, &z, &end);
if (got < 3)
break;
v[num_v] = vertex_add(
- round(x*1000), round(-y*1000), round(z*1000));
+ roundf(x*1000), roundf(-y*1000), roundf(z*1000));
if (++num_v == 3) {
facet_add(v[0], v[1], v[2]);
state = s_endloop;