Havok time step has been decreased by more than a factor of 4.0000 warning

Havok time step has been decreased by more than a factor of 4.0000 warning

I've added havok into my game and i run my game and it lags like crazy and the warning:
havok time step has been decreased by more than a factor of 4.0000 shows up everytime I step havok.

12 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Havok_Amy's picture

Hi Arturs,

Is this a havok warning? If it is, can you post the id that should be printed with this warning as I can't find any warning in our code that uses the text string you've listed.

Amy Developer Support Engineer Havok www.havok.com

Hi Amy,

I think Arturs is referring to this warning:

World\Simulation\hkpSimulation.cpp(232): [0x2A2CDE91] Warning: Simulation may become unstable, the time step has decreased by more than a factor of 4.000000 from the previous step 

I'm also curious about the nature of this warning; I'm using the simplest form of stepping the world forward:

world->stepDeltaTime((hkReal)timestep);

where 'timestep' is constant, but the phrasing of the warning suggests a variable time-step under the hood...

 

Tom E. is right, that's the warning. It's gone now but who knows, it could come back after putting some code in. So it would be great if you could reply letting me know the cause of this error.

Well, who would have guessed it. The warning decided to come back to me. The error actually causes the simulation or the game loop to lag and everything becomes very glitchy and laggy.

Havok_Amy's picture

Hi Artus,

This warning fires(as it implies) if the timestep used to step the world is less than 4 times what it was during the last frame. Havok requires you use a constant timestep in order to get a stable simulation. If you aren't already doing so, try setting your deltaTime for the physic step to a fixed value. You shouldn't see this warning any more and the simulation should more stable as well.

The manual under section: Creating a Simulation -> Simulating a Physics 2012 World -> Stepping the Simulation, covers this area in more detail and discusses doing "Asynchronous Stepping" (rendering has a varying frame rate, but physics a fixed frame rate), and also the extent to which Physics2012 can handle variable timesteps (basically <10% variance).

P.S. apologies for the late responses, we have been a bit under-resourced recently, please bear with us

Amy Developer Support Engineer Havok www.havok.com

Thank you for letting me know. I would be normally running multiple applications while creating my game so when I run it its most likely going to lag and show that error. So now when I ran it alone. It goes fine. It only shows the error for the first 2 or so seconds of the simulation and after that it's all fine.

Havok_Amy's picture

Hi Arturs,

Other applications should not change the timestep used to simulate the physics world. They may cause the time it takes to step the world to take longer but the physics world should still only be stepped at a constant rate 

For example, if you tell the physics world to step forward 0.016sec but because your machine is busy doing other things it could take much longer, say 0.05sec, to finish calculating. Now, even though in real world time we have progress 0.05sec into the future, the physics world has only moved 0.016 sec into the future. For the next frame you should still be using 0.016sec as your world step, so that warning should not fire no matter how many other applications you have running (although the simulation may look like its running in slow motion).

Amy Developer Support Engineer Havok www.havok.com

Hi Amy,

Thanks for getting back to us. In order to make sure I'm not actively changing the timestep on my side, I edited the offending line with a constant:
hkpStepResult r = world->stepDeltaTime((hkReal)0.002);
and I still get that warning.
Could there be something else going on?

Havok_Amy's picture

Hi Tom,

That really shouldn't be happening then with the constant timestep value. Is it possible you are still steppping the world somewhere else in your code (with a different timestep)? If you comment out the line "hkpStepResult r = world->stepDeltaTime((hkReal)0.002);" does the warning go away? (the world should also then be stationary)

Amy Developer Support Engineer Havok www.havok.com

Hi Amy,

It happens on the very first call, and not again (I verified this is indeed the only call in my code).

Maybe the default value is bigger than 4*0.002, and so switching to 0.002 is a significant reduction?  Is there a way to change this value without stepping?  alternatively, is there a way to suppress this warning?

Havok_Amy's picture

Hi Tom,

Ok, it being only on the first frame does make more sense. Yes the inital value set in the world constructor is 0.0166 (60fps) so your value of 0.002 will fire this warning on the first frame.

I would suggest just ignoring the warning since it is only for the first frame, it won't be checked when you run in release (only in debug or dev) so your final application won't show this warning anyway.
You can also turn off a warning by disabling it: "hkError::getInstance().setEnabled(warningID, false);" but be careful doing this as you then won't be notified for times when this warning fires correctly (unlikely for this one since you are using a constant timestep, but it is just a word of caution that I must really stress).

Amy Developer Support Engineer Havok www.havok.com

Login to leave a comment.