I've back to do more programming. I've been trying to implement collision detection in ODE for the Minas Tirith project (which incidently, is using Infinity's engine: combo hit). It didn't work quite well. As soon as two objects were colliding, they ended up with a NaN (not-a-number) position/velocity. I tracked down the problem into ODE to find a very strange thing..
Picture this: a structure dContact, contains collision detection informations about the contact, its position, normal, penetration, etc.. I've got an array of these (in C++: dContact contacts). Easy, huh ?
Hell no: typing in the debugger sizeof(dContact) returned 196, while sizeof(contacts)) returned 200. An offset of 4 bytes, coming from nowhere, while the two are "logically" equivalent.. how is that possible ?
Well, the thing is, it's perfectly possible. After spending a couple of hours debugging that thing, i found the cause of the problem: in another DLL, a header file was setting the pack alignment of structures to 1, then setting it back to the default, 4. Excepting that.. the default in VC is not 4, but 8 :) A stupid mistake which caused the dContact structure to be defined virtually twice: one with a pack alignment of 4 (the one included by the application, which is using the other DLL); and the one with a pack alignment of 8, included by ODE.
Cool, isn't ? I love programming.
In other news, i've received a first version of the space station Shawn is modelling. It's full of mapping errors, but as it appears correctly in 3ds max, it means i've got a serious bug in my exporter code. That's weird, too, because i've exported tons of models with that exporter before, and the texture coordinates has always looked good. More debugging to come.. sic.