Hi
apparently lib3ds is broken when compiled with gcc 4.0.x.
Some details can be found here:
http://sourceforge.net/tracker/index.php?func=detail&aid=1249100&group_id=4041&atid=104041
I can confirm that this report is definitely correct. The symptoms on a system
I just finished debugging are that all pointL[point].pos[i] (and probably all
other floating point values, but this particular array is easy to debug)
entries are invalid (6.22713e-39 in my case - for _all_ vertices).
The problematic line is apparently:
return(*((Lib3dsFloat*)&d));
The problem seems to go away when
* compiled with -O0 (not tested whether lib3ds works then, but my test
application that uses the above line works then)
* compiled with gcc < 4.0
* the b array is printf()'ed before the return (I suspect gcc then can't do
the problematic optimizations)
The fix suggested in the mentioned link indeed fixes the problem.
I have implemented it against current cvs. A patch is attached. Could someone
with cvs access please apply it?
Thanks a lot
CU
Andi
Index: io.c
===================================================================
RCS file: /cvsroot/lib3ds/lib3ds/lib3ds/io.c,v
retrieving revision 1.3
diff -u -3 -p -r1.3 io.c
--- io.c 11 Jul 2001 13:47:35 -0000 1.3
+++ io.c 29 Dec 2005 09:29:13 -0000
@@ -247,16 +247,17 @@ lib3ds_io_read_intd(Lib3dsIo *io)
Lib3dsFloat
lib3ds_io_read_float(Lib3dsIo *io)
{
+ union f_and_dw { Lib3dsDword dwval; Lib3dsFloat fval;};
Lib3dsByte b[4];
- Lib3dsDword d;
+ union f_and_dw d;
ASSERT(io);
lib3ds_io_read(io, b, 4);
- d=((Lib3dsDword)b[3] << 24) |
+ d.dwval=((Lib3dsDword)b[3] << 24) |
((Lib3dsDword)b[2] << 16) |
((Lib3dsDword)b[1] << 8) |
((Lib3dsDword)b[0]);
- return(*((Lib3dsFloat*)&d));
+ return d.fval;
}