[ODE] Joints send bodies to NaN

Nate W coding at natew.com
Wed Feb 20 14:16:01 2002


On Wed, 20 Feb 2002, Daniel Duhprey wrote:

> I must apologize.  My initial WorldStep was zero which caused the failure.  
> The downside, I guess, of trying to set the step size relative to the 
> fremerate.

I ran into the same thing.  I got around it by constraining the time step
with user-settable maximum and minumum values.  Maybe something like this
should be in the docs, or in the sample code?  It seems to be a common
pitfall.

// compute time delay (GetTickCount is a Win32 thing)
UINT32 uThisTimerTick = GetTickCount (); 
UINT32 uMilliseconds = uThisTimerTick - m_uLastTimerTick;
m_uLastTimerTick = uThisTimerTick;

// constrain delay period
if (uMilliseconds > m_uMaxDelta)
	uMilliseconds = m_uMaxDelta;

if (uMilliseconds < m_uMinDelta)
	uMilliseconds = m_uMinDelta;

// just in case the user set a minimum delta of zero...
if (uMilliseconds <= 0)
	uMilliseconds = 10;

double rElapsedTime = (real) uMilliseconds / 1000.0;
dWorldStep (m_WorldID, rElapsedTime);


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