My simulator server (MS FSX) has the ability of time compression/dilation, which user can select through UI. Basically, time compression/dilation allows simulation to run faster or slower than the normal time. This is very useful in spaceflight where there may be long periods of time where spacecraft is orbiting towards the next event without any need for spacecraft control (almost like an autopilot). I need to apply this setting to my spaceflight module, which uses Newton Game dynamics. The time compression settings available are:
timeCompression: 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 128
I use these values to multiply them with timestep and pass it on into NewtonUpdate():
- Code: Select all
NewtonUpdate(m_world, timestep*timeCompression)
However, I am not getting the consistent results: As I am testing this on a spacecraft that's orbiting around Earth, time dilation is working fine with values of 0.25 and 0.5. Time compression is working, however, when I pass values of 8 and larger, there are "hiccups" (random short pauses).
This USED to work with builds from about 2 years ago, where there was a define DG_MAX_TIMESTEP, which I remember I had to adjust to make all the values work properly. However, newer builds got rid of it and, looking at the code, I am unsure what the problem might be. Obviously, NewtonUpdate() has a problem dealing with larger time steps. I am using identical code to what is in
- Code: Select all
void DemoEntityManager::UpdatePhysics(dFloat timestep)
of the sandboxDemo. I have to admit that I am not entirely sure how this code works (I think it limits running physics at MAX_PHYSICS_FPS, set at 60 fps) and there is perhaps a step I am missing that will make the time dilation/compression work properly.
So, is there anything I'm doing wrong with implementing this functionality? Does anyone know how to properly speed up or slow down time in Newton?
Thanks,
Misho