[ODE] Strange error when using single precision

Nate W coding at natew.com
Sat Sep 21 23:21:01 2002


On Sat, 21 Sep 2002, Peter Thoman wrote:

> The following function works perfectly fine when linking with an ode.lib 
> built with doubles, however if I  switch to singles it gives me an error 
> message saying "ODE INTERNAL ERROR 2 - BAD DIRECTION NUMBER" and my 
> debugger points me to the dMassSetCappedCylinder line.
> 
> void setMass()
> {
>     dMass m;
>     dMassSetCappedCylinder(&m, 20.0f, 3, 1.0f, 2.5f);
>     dBodySetMass(mODEBody,&m);
> }

When I switched from double to float (also for tri-collider), I ran into a
bunch of problems involving pointers to values.  If a function expects a
pointer to one type and gets a pointer to a different floating-point type,
the resulting behavior is, as we say, "undefined."  

If you're not recompiling the application when you try different versions
of the ode.lib, I'd wager that you're running into this kind of problem.  
If the .exe is built with dDOUBLE and the .lib is built with dSINGLE,
you'll have functions expecting pointers to single-precision values, but
getting passed pointers to double-precision values.  

-- 

Nate Waddoups
Redmond WA USA
http://www.natew.com